Link Search Menu Expand Document

Implementation Steps

The SDK must be initialised in your AppDelegate

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

Steps
  1. Initialise the SDK in your App Delegate
  2. Initialise the CTContext object with the required parameters
  3. Present the SDK via Modal or Push Presentation
    1. Start Standalone flow on the Landing Page
    2. Start Standalone flow on the Vehicle List (bypass Landing Screen and Search Screens)
    3. List of Parameters
Optional Extras
  1. Start the Standalone Flow on Another Screen
  2. Start the Standalone Flow via URL Deeplink
  3. Prepopulate Driver Details

Initialise the SDK in your App Delegate

import CarTrawlerSDK

// In application(_:didFinishLaunchingWithOptions:)
CarTrawlerSDK.sharedInstance().initialiseSDK(with: nil,
                               customParameters: nil,
                               production: false)

The production parameter must be set to true when submitting your app to the AppStore.

style: An optional CTStyle object, used to set the fonts as well as the primary, secondary, and accent colors in the SDK. Please ensure any custom fonts used are included in your main bundle.

customParameters: A dictionary of parameters, custom to a particular partner, see below for options.
- orderID: A String value that represents the Order ID for a Flight PNR or Booking Reference, example: IE1234 (limited to 32 characters)
- flightNumberRequired: A boolean key to enable Flight Number as a required field in the Payment Form. Default: 0 (optional field)


For a full list of property descriptions, please click here


Initialise the CTContext object with the required parameters

This can be done in the view controller the SDK will be presented from.

The implementationID is needed by the SDK to fetch partner specific configuration.

import CarTrawlerSDK
let context = CTContext(implementationID: "your implementation ID", 
                        clientID: "your client ID", 
                        flow: .standAlone)
context.countryCode = "IE" // The country code associated with the device’s system region is used by default.
context.currencyCode = "EUR" // The currency associated with the device’s system region is used by default.
context.languageCode = "EN" // The language associated with the device’s system region is used by default.

The above properties are required, and the countryCode property refers to the country of residency. This is used to make search requests.

Object Description

class CTContext: NSObject {
  let implementationID: String
  let clientID: String
  let flowType: CTFlowType
  let countryCode: String
  let currencyCode: String
  let pickupDate: Date
  let dropOffDate: Date
  let pickupLocation: String
  let dropOffLocation: String
  let flightNumber: String
  let pickupLocationID: String
  let dropOffLocationID: String
  let pinnedVehicleID: String
  let passengers: [CTPassenger]
  let loyaltyRegex: String
  let customCashTreatment: Bool
  let promotionCode: String
  let recentSearch: CTRecentSearch
  let supplierBenefitAutoApplied: Bool
  let clientUserIdentifier: String
  let settingsIconType: CTSettingsIconType 
}

Click here for an in depth explanation of CTContext’s properties.


Present the SDK via Modal or Push Presentation

In the view controller you wish to present the SDK from, add the following code after configuring your CTContext:

let viewController = UIViewController()
CarTrawlerSDK.sharedInstance().present(from: viewController, context: context)

Alternatively, in the navigation controller you wish to push the SDK from, add the following code after configuring your CTContext:

let navigationController = UINavigationController()
CarTrawlerSDK.sharedInstance().push(fromNavigationViewController: navigationController, context: context)

Start the Standalone Flow on Another Screen

When launching the Standalone flow, it is possible to bypass the landing and search screens by setting certain properties of your CTContext object.
This is entirely optional.


Start Standalone flow on the vehicle list via Pickup & Drop Off (bypass the landing and search screens)

For this alternate starting point in the flow, pick-up and drop-off locations and dates must be provided.

// Create a context for the Standalone flow
let context = CTContext(implementationID: "your implementation ID", 
                        clientID: "your client ID", 
                        flow: .standAlone)

// Set required properties
context.countryCode = "IE" // The country code associated with the device’s system region is used by default.
context.currencyCode = "EUR" // The currency associated with the device’s system region is used by default.
context.languageCode = "EN" // The language associated with the device’s system region is used by default.

// Set pick-up and drop-off locations using location or IATA codes
// Pick-up at Dublin Airport
context.pickupLocationID = "11" // or context.pickupLocation = "DUB"
// Drop-off at Cork Airport
context.dropOffLocationID = "1316" // or context.dropOffLocation = "ORK"

// Sample dates
var dateComponent = DateComponents()
dateComponent.month = 1
let nextMonth = Calendar.current.date(byAdding: dateComponent, to: Date())
dateComponent.day = 3
let nextMonthPlusThreeDays = Calendar.current.date(byAdding: dateComponent, to: Date())

// Set pick-up and drop-off dates
context.pickupDate = nextMonth! // next month sample date
context.dropOffDate = nextMonthPlusThreeDays! // next month + 3 days sample date

// Set your viewController as the CarTrawlerSDK delegate 
context.delegate = self

A vehicle can be pinned to the top of the list by setting pinnedVehicleID (adding a vehicle reference ID). To get a reference ID, you can use our Vehicles API.

context.pinnedVehicleID = "1892038" // Vehicle RefID

Click here for an in depth explanation of the relevant CTContext properties


Start Standalone Flow on the Vehicle List via Recent Search (bypass the landing and search screens)

For this alternate starting point in the flow, a recent search (CTRecentSearch object) must be provided.

// Create a context for the Standalone flow
let context = CTContext(implementationID: "your implementation ID", 
                        clientID: "your client ID", 
                        flow: .standAlone)
context.countryCode = "IE" // The country code associated with the device’s system region is used by default.
context.currencyCode = "EUR" // The currency associated with the device’s system region is used by default.
context.languageCode = "EN" // The language associated with the device’s system region is used by default.
context.recentSearch = recentSearch // your recent search object fetched from the recent searches api. 
context.delegate = self

To get a recent search, you can use our Recent Searches API.

Click here for an in depth explanation of the relevant CTContext properties


It is possible to launch the Standalone flow using a 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://host?param1=123&param2=abcd&paramN=xyz

This example will open the vehicle list / search results page:
schema://ct-car-rental?type=search-result&client_id=123456&pt=2023-09-08T09:44:35+0100&dt=2023-09-10T10:44:35+0100&pkIATA=DUB

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

Similar to the methods listed previously for launching the Standalone flow, the URL is used by CTContext. A separate initialiser exists for this purpose:

let url = "airline://ct-car-rental?type=search-result&client_id=123456&pt=2023-09-08T09:44:35+0100&dt=2023-09-10T10:44:35+0100&pkIATA=DUB"
let context = CTContext(implementationID: "your implementation ID", appDeeplinkURL: url)

You can then present the SDK:

CarTrawlerSDK.sharedInstance().present(from: self, context: context)

See here for more details


Start Standalone flow on the Landing Page

To open the SDK on the landing page, simply set the type to landing: type=landing

Start Standalone flow on the Vehicle List (bypass Landing Screen and Search Screens)

To open the SDK on the vehicle list page, set the type to search-result: type=search-result

Make sure to provide pickup and drop off dates, and a pickup location ID, or IATA code. If any of these are missing, the SDK will instead open on the landing page.

Start Standalone flow on the Manage Booking screen

To open the SDK on the manage booking screen, simply set the type to booking-details: type=booking-details and make sure to provide the booking id and email. Email is only required to import the booking if it was made through a different platform (e.g Android, Web)

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
Manage Booking
ParameterExampleRequired
typebooking -detailsyes
client_id123456yes
ctyCode (residency)IEno
ccy (currency)EURno
bookingIE123456789yes
emailmail@mail.comno (only required if importing the booking from a different platform)
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
pl (pickup location ID)11yes (if pkIATA not set)
dl (drop off location ID)11no
age30no
ctyCode (residency)IEno
ccy (currency)EURno
pinVeh (pinned vehicle)123456789no

Adding Flight Information

For enhanced reporting partners can optionally add flight data when initialising the SDK. Each of these parameters is optional and user functionality will not be impacted whether they are added or not.

A new CTFlightDetails object is added with the following parameters.

ParameterDescriptionExampleType
ageCustomer age29Integer
bagsTotal number of bags. Both Cabin and Hold should be included3Integer
basketAmountTotal basket amount including bags, seats, etc.130.99Float
campaignIDUnique identifier associated with a specific marketing campaign.Google-EN-Destination-FranceString
contextWhere in the flow the SDK is loadedConfirmation ScreenString
fareClassType of fareEconomyString
flightFarePrice of flight(s) only101.99Float
loyaltyNumberCustomer loyalty number123222121String
loyaltyTierCustomer loyalty tierPlatinumString
marketingPreferenceFlag to indicate if the current user has opted in for third-party marketing i.e car rentaltrueBoolean
marketingSegmentThe customers segment as determined by the airline marketing team.Weekend BreakerString
membershipIDOnly required if different from loyaltyNumber. This value represents the logged in users unique identifier.789String
passengerBreakdownBreakdown of Adults, Teens, Children and InfantsCTFlightPassengerBreakdown(adults: 2, teens: 0, children: 0, infants: 0)CT Object
pnrFlight PNRCT123456String
sessionIDCurrent user session identifier0idfw78jsnkooString
sportsEquipmentTotal number of sports equipment items a customer is travelling with1Integer
sportsEquipmentBreakdownA breakdown of the individual equipment a customer is travelling with[“golf”: (1), “ski”: (1), “surf”: (1)]Dictionary
tripDurationTotal length of trip in days4Integer
tripTypeAn identification of whether the trip type is business, leisure or otherBusinessString
//Example CTFLightDetails initialisation

let flightDetails = CTFlightDetails()
flightDetails.age = 32
flightDetails.bags = 2
flightDetails.basketAmount = 130.99
flightDetails.campaignID = "Google-EN-Destination-France"
flightDetails.context = "confirmation"
flightDetails.fareClass = "regular"
flightDetails.flightFare = 101.99
flightDetails.loyaltyNumber = "WZ123456789"
flightDetails.loyaltyTier = "platinum"
flightDetails.marketingPreference = true
flightDetails.marketingSegment = "Budget Conscious"
flightDetails.membershipID = "123222121"
flightDetails.passengerBreakdown = CTFlightPassengerBreakdown(adults: 2, teens: 0, children: 0, infants: 0)
flightDetails.pnr = "TEYI89"
flightDetails.sessionID = "0idfw78jsnkoo"
flightDetails.sportsEquipment = 2
flightDetails.sportsEquipmentBreakdown = ["golf": (1), "ski": (1), "surf": (1)]
flightDetails.tripDuration = 4
flightDetails.tripType = "business"
        
//Use CTFLightDetails as part of the context
let context = CTContext(implementationID: "your implementation ID",
clientID: "your client ID",
flow: .standAlone)
    
context.flightDetails = flightDetails


Adding UTM tracking data

For enhanced reporting partners can optionally add tracking data in the form of UTM parameters. The meaning and usage of these parameters are as standard.

A new CTUTMParameters object is added with the following parameters.

//Example CTUTMParameters initialisation
let utmParameters = CTUTMParameters()
utmParameters.source = "partner_utm_source"
utmParameters.medium = "partner_utm_medium"
utmParameters.campaign = "partner_utm_campaign"
utmParameters.term = "partner_utm_term"
utmParameters.content = "partner_utm_content"
        
context.utmParameters = utmParameters

Prepopulate Driver Details:

The Driver Details screen can by prepopulated by creating a CTPassenger object and setting the passengers property on your CTContext.

//Passenger object
let passenger = CTPassenger(firstName: "Ryan",
                            lastName: "O'Connor",
                            addressLine1: "DunDrum",
                            addressLine2: "Dublin 14",
                            city: "Dublin",
                            postcode: "Dublin 14",
                            countryCode: "IE",
                            age: 25,
                            email: "ryan.oconnor@cartrawler.com",
                            phone: "0838880000",
                            phoneCountryPrefix: "353",
                            loyaltyProgramNumber: "1234")
context.passengers = [passenger]

CTPassenger countryCode takes priority over CTContext’s countryCode property when we make search requests.