Booking Screen

UI SDK

The booking screen is the main point of entry into the UI SDK. From the booking screen the user can select a pickup point, a destination and a booking time ("ASAP" if left blank). Once the data are provided, a user shall be navigated to next screen - Quotes list.

11701170 517517

Clicking on the pickup or drop off input fields will take the user to the address screen.

📘

Location Permission Access

Ensure that the user has granted location permissions when instantiating the Android booking screen. If these haven't been granted then the user will be unable to use the map to select an address and the pickup address will not default to the user's location.

Authenticated user flow
Authenticated users will be able to book with a pre-saved card(s) or add a new one to be used for payment. Once the booking is complete, an authenticated user is taken to the trip screen. Guest users are taken to a webview showing the trip tracking.

Standard booking flow

To launch a booking screen with the standard flow that takes the user to the trip screen after booking (so once the Checkout screen flow is done), construct the Intent using the BookingActivity builder and startActivity().

Alternate callback flow

The booking screen can also be launched with the flow returning to your app instead of the trip screen on booking completion.

To initiate the callback flow, construct the Intent with the method buildForOnActivityResultCallback(context: Context): Intent instead of the usual build(context: Context) method and pass this into startActivityForResult() with your own request code. When the activity returns to your onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) method, you will be able to retrieve the TripInfo object by calling data?.getParcelableExtra(BookingCodes.BOOKED_TRIP).

// launching for primary flow
val builder = BookingActivity.Builder.builder
                .initialLocation(location)
                .outboundTripId(outboundTripId)
                .comments(comment)
                .passengerDetails(passenger)
                .journeyInfo(journeyInfo)
                .tripDetails(tripDetails)
                
startActivity(builder.build(this))

// launching for callback example
val MY_REQ_CODE = 101
val callbackIntent = BookingActivity.Builder.builder
    .initialLocation(location)
    .buildForOnActivityResultCallback(this)
startActivityForResult(callbackIntent, MY_REQ_CODE)

// receiving booked trip for callback flow
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
  if (resultCode == Activity.RESULT_OK && requestCode == MY_REQ_CODE) {
    val bookedTrip = data?.getParcelableExtra<TripInfo>(BookingCodes.BOOKED_TRIP)
    // do something with bookedTrip 
  }
  super.onActivityResult(requestCode, resultCode, data)
}
// returns navigation controller instance with BookingScreen set as root view controller
let booking = KarhooUI().screens().booking().buildBookingScreen()

self.present(booking!,
             animated: true,
             completion: nil)

The booking screen initially presents the address and map views. When the the pick up and drop off points are set, the quote list is presented with a list of quotes from suppliers. Clicking on a quote item takes the user to the booking details screen.

tripDetails: TripInfoThe activity will take the origin and destination, if available from tripDetails, use this to pre-populate the addressview and begin fetching quotes
outboundTripId: StringThe outboundTripId is expected when the trip is booked from a ‘rebook’ button in another activity, it’s used for analytics purposes only
initialLocation: LocationIf an initialLocation is passed in the activity will zoom straight to this without having to wait for the device to return a location
comments: StringBy passing a comment into the Booking activity it will automatically prefill the comments field of the desired trip.
passengerDetails: PassengerDetailsBy passing passenger details into the Booking activity it will automatically prefill the passenger details of the desired trip.
journeyInfo:JourneyInfoWhen passing a journeyInfo into the Booking activity it will automatically prefill the origin, destination and date of the desired trip.

What’s Next