Implementation Steps
To implement the SDK’s Standalone flow within your app, please use the following steps:
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
CTSdkDatabuilder 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
navigateToof typeCTStandaloneNavigation. If you’re using Kotlin you can omit it since its default value isCTStandaloneNavigation.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 byCTNavigateToAvailabilityWithPinnedVehicle,CTNavigateToAvailabilityWithRecentSearchandCTNavigateToBookingDetailsis not used by the web booking flow; to start from a recent search, copy its location and dates intoCTSdkData.
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).
Start the Standalone flow via URL Deeplink
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¶m2=abcd¶mN=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
| Parameter | Example | Required |
|---|---|---|
| type | landing | yes |
| client_id | 123456 | yes |
| ctyCode (residency) | IE | no |
| ccy (currency) | EUR | no |
Search Results
| Parameter | Example | Required |
|---|---|---|
| type | search-result | yes |
| client_id | 123456 | yes |
| pt (pickup time) | 2023-08-18T10:00:00Z | yes |
| dt (drop off time) | 2023-08-20T10:00:00Z | yes |
| pkIATA (pickup IATA) | DUB | yes (if pl not set) |
| doIATA (drop off IATA) | DUB | no |
| pkLtLng (pickup coordinates) | 53.3333,-6.24089 | yes (for geo search) |
| doLtLng (drop off coordinates) | 53.3333,-6.24089 | no |
| pl (pickup location ID) | 11 | yes (if pkIATA not set) |
| dl (drop off location ID) | 11 | no |
| age | 30 | no |
| ctyCode (residency) | IE | no |
| ccy (currency) | EUR | no |