SplytWidgetSDK

The SplytWidgetSDK allows you to easily make ride hailing available to users of your app. Using the SplytWidgetSDK you can present your users with a clean, simple and logical interface.

Requirements

  • iOS 11.0 or later
  • Xcode 8.0 or later

Installing

Before installing the SplytWidgetSDK, you will need your PartnerId. If you haven’t received this, please contact Splyt who will be happy to provide this for you.

The SplytWidgetSDK is most easily installed using CocoaPods. If your XCode project is not yet setup for Cocopods usage, read the guides here for how to get started.

The SplytWidgetSDK is hosted in a private Cocoapods Specs Repo. You will need to add this specs repo to your development machine.

cd ~/.cocoapods/repos
pod repo add splyt-ios-pods git@github.com:splytech-io/splyt-ios-pods.git

You will need to add the following lines to the top of your Pod file. This informs Cocoapods which specs repo’s to search in order to satisfy the listed dependencies.

source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/splytech-io/splyt-ios-pods.git'
  1. Add a pod entry of SplytWidgetSDK to your Podfile. pod 'SplytWidgetSDK'
  2. Install the pod(s) by running pod. pod install

Note When importing the SplytWidgetSDK into an Objective-C based project, the build setting Always Embed Swift Standard Libraries must be set to Yes.

How to use the SplytWidgetSDK

Import the framework into your code.

Example

Swift:

import SplytWidgetSDK

Objective C:

@import SplytWidgetSDK;

The SplytWidgetSDK contains a static class named SplytWidget. To launch the SplytWidget you must call the initWidget method.

This method accepts three arguments. The first parameter is an instance of SWConfiguration which is created using the SWConfigurationBuilder. The second parameter is a subscriber of the SplytWidgetDelegate. This delegate will receive various callbacks that need to be implemented in order for the SplytWidget to function correctly. The final parameter is a closure that receives an optional SWError object and optional UIViewController. If the closures receives an error, the widget viewController will not be returned. The error contains a code which indicates which configuration object is invalid. If the closure receives the parameter widget then it is safe to present the widget to your user.

Example

Swift:

SplytWidget.initWidget(configuration: builder.build(),
                        delegate: self()) {
                          widget, error in
  if widget != nil {
    self.present(widget!, animated: true, completion: nil)
  }
}

Objective C:

[SplytWidget initWidgetWithConfiguration:[configBuilder build]
                                   delegate:self
                                 completion:^(UIViewController *_Nullable, SWError * _Nullable) {

 }];

Configuring the SplytWidget

When presenting the SplytWidget you are required to pass an instance of SWConfiguration. To create the SWConfiguration you should use the SWConfigurationBuilder. The SWConfiguration model allows you to fine tune the widget for you app.

Example

// Set the widget user in the ride parameters.
let rideParams = SWRideParametersBuilder()
    .set(userId: "Your users id")
    .build()

// Define a default location to use for centring the map (only used if GPS is not allowed).
let defaultLocation = SWLocation(latitude: Double(51.511237),
                                 longitude: Double(-0.141083))

// Create the configuration params
let config = SWConfigurationBuilder()
    .set(defaultLocation: defaultLocation)
    .set(requestNotificationPermission: true)
    .set(requestLocationPermission: true)
    .set(rideParameters: rideParams)
    .set(currencyCode: "GBP")
    .set(locale: "en-us")
    .set(partnerId: "demo-partner-id")
    .set(primaryColor: "#4265f4")
    .build()

SplytWidget.initWidget(configuration: builder.build(),
                        delegate: self()) {
                          widget, error in
}

Out of the box, the SplytWidget allows a user to input pickup/dropoff locations manually. Using the SWRideParametersBuilder you can automatically set the pickup location.

Example


let pickup = SWLocation(latitude: Double(51.511237),
                        longitude: Double(-0.141083))

// Set the widget user in the ride parameters.
let rideParams = SWRideParametersBuilder()
    .set(userId: "Your users id")
    .set(pickupLocation: pickup)
    .build()