Link Search Menu Expand Document

Implementation Steps

To implement the SDK’s Standalone flow within your app, please use the following steps:

Steps
  1. Initialise the SDK
  2. Initialise CTSdkData
  3. Starting the flow
Alternative Standalone starting points

Initialise the SDK

Initialise the SDK by calling the init method in the CartrawlerSDK class as follow:

val partnerImplementationID = "your-implementation-id-here"
val environment = CTSdkEnvironment.DEVELOPMENT // CTSdkEnvironment.PRODUCTION

CartrawlerSDK.init(partnerImplementationID, environment)

The implementationID is needed by the SDK to fetch partner specific configuration, including the web booking flow configured for you. It’s recommended to call CartrawlerSDK.init in your application class.

Don’t forget to use CTSdkEnvironment.PRODUCTION when submitting your app to the Play Store.


Initialise CTSdkData

val sdkDataClientIdXYZ = CTSdkData.Builder(clientId = clientId)
    .country(twoLetterISOCountry = "IE")
    .currency(currency = "EUR")
    // check Property Descriptions link down below to see all available properties

Optional properties

The CTSdkData builder also has some optional properties that are forwarded to the booking flow, you can check Property Descriptions section for all properties available.


Starting the flow

CartrawlerSDK.start(
    activity = this, 
    requestCode = YOUR_REQUEST_CODE_HERE, 
    ctSdkData = sdkDataClientIdXYZ.build(), 
    flow = CTSdkFlow.Standalone()
)

The SDK opens the CarTrawler web booking flow configured for your implementationID. The search, vehicle list, extras, insurance, payment and confirmation steps are all rendered by the web booking flow.

Standalone Navigation types

Standalone flow accepts a parameter navigateTo of type CTStandaloneNavigation. If you’re using Kotlin you can omit it since its default value is CTStandaloneNavigation.CTNavigateToLanding.

The following types are allowed:

CTStandaloneNavigation.CTNavigateToLanding
CTStandaloneNavigation.CTNavigateToAvailability
CTStandaloneNavigation.CTNavigateToAvailabilityWithPinnedVehicle("<vehicle_ref_id_here>")
CTStandaloneNavigation.CTNavigateToAvailabilityWithRecentSearch(<ct_recent_search_data_here>)
CTStandaloneNavigation.CTNavigateToBookingDetails(<ct_booking_here>)
CTStandaloneNavigation.CTNavigateWithDeepLink("<url_here>")

All navigation types open the web booking flow. Where the flow opens is driven by the search data in CTSdkData (pick-up/drop-off location and dates): if a search location and dates are provided, the web booking flow opens with that search applied, otherwise it opens on the web search page. The extra data carried by CTNavigateToAvailabilityWithPinnedVehicle, CTNavigateToAvailabilityWithRecentSearch and CTNavigateToBookingDetails is not used by the web booking flow; to start from a recent search, copy its location and dates into CTSdkData.

The requestCode is defined by the consumer app, since it will need to use it inside its onActivityResult conditional to capture the reservation details that the SDK sends back to the consumer app. See Reservation Retrieval.


Start the Standalone flow on the search results

Provide a pick-up location and dates in CTSdkData so the web booking flow opens directly on the search results:

val sdkDataClientIdXYZ = CTSdkData.Builder(clientId = clientId)
    .pickupDateTime(LocalDateTime.of(2023, 5, 10, 10, 0))
    .dropOffDateTime(LocalDateTime.of(2023, 5, 15, 10, 0))
    .pickupLocationIATA("DUB")

CartrawlerSDK.start(
    activity = this,
    requestCode = YOUR_REQUEST_CODE_HERE,
    ctSdkData = sdkDataClientIdXYZ.build(),
    flow = CTSdkFlow.Standalone(navigateTo = CTStandaloneNavigation.CTNavigateToAvailability)
)

When CTNavigateToAvailability is used without a drop-off date, the web flow uses the pick-up date plus the partner-configured default rental length (3 days if not configured).


It is possible to launch the Standalone flow using an URL, which may come from a push notification or native app deep link for example. This is entirely optional.

The URL should have the following pattern:
schema://ct-car-rental?param1=123&param2=abcd&paramN=xyz

This example will open the web booking flow on the search results:
schema://ct-car-rental?type=search-result&client_id=your-client-id&pt=2023-08-18T10:00:00Z&dt=2023-08-20T10:00:00Z&pkIATA=DUB&doIATA=ORK

A client ID (client_id) must be provided as part of your URL in order for the SDK to function properly.

Once you have the URL you can call the following method to launch the SDK:


val deepLinkURL = "schema://ct-car-rental?type=landing&client_id=your-client-id"
val isLoggingHttpRequests = BuildConfig.DEBUG
val ctSdkData = CTSdkData.Builder("")
    .theme(R.style.your-theme-here)
    .darkModeConfig(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
    .logging(isLoggingHttpRequests)
        
CartrawlerSDK.start(
    activity = this,
    requestCode = YOUR_REQUEST_CODE_HERE,
    ctSdkData = ctSdkData.build(),
    flow = CTSdkFlow.Standalone(navigateTo = CTStandaloneNavigation.CTNavigateWithDeepLink(deepLinkURL))
)

The URL parameters are applied to the search sent to the web booking flow (location, dates, driver age, residency and currency).

Start the Standalone flow on the web search page

Set the type to landing: type=landing

Start the Standalone flow on the search results

Set the type to search-result: type=search-result, and make sure to provide pickup and drop off dates, and a pickup location ID, IATA code or coordinates. If any of these are missing, the SDK opens the web search page instead.

List of Parameters

Below are all the available parameters for use in the URL.

Landing
ParameterExampleRequired
typelandingyes
client_id123456yes
ctyCode (residency)IEno
ccy (currency)EURno
Search Results
ParameterExampleRequired
typesearch-resultyes
client_id123456yes
pt (pickup time)2023-08-18T10:00:00Zyes
dt (drop off time)2023-08-20T10:00:00Zyes
pkIATA (pickup IATA)DUByes (if pl not set)
doIATA (drop off IATA)DUBno
pkLtLng (pickup coordinates)53.3333,-6.24089yes (for geo search)
doLtLng (drop off coordinates)53.3333,-6.24089no
pl (pickup location ID)11yes (if pkIATA not set)
dl (drop off location ID)11no
age30no
ctyCode (residency)IEno
ccy (currency)EURno