Quick Start

iOS

Check our public sample application for an actual implementation of the snippets below and how they can be utilized.

Overall Code

A quick start snippet will look something like this in your app's willFinishLaunchWithOptions:

import MoveSDK

func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
     
    MoveSDK.shared.setSDKStateListener { state in
        switch state {
        case .uninitialized:
            /* SDK uninitialized*/
            break
        case .ready:
            /* SDK initialized and ready to start the service*/
            MoveSDK.shared.startAutomaticDetection()
        case .running:
            /* SDK Started Detection*/
            break
        case let .error(error):
            switch error {
            /* Hanlde SDK State Errors*/
            default: break
            }
        }
    }
 
    let sdkConfig = MoveConfig(timelineDetectionService: 
                    [.walking, .driving, .bicycle, .places, .publicTransport], 
                    drivingServices: [.dfd, .behaviour], 
                    otherServices: [.poi])
 
    MoveSDK.shared.initialize(auth: auth, config: sdkConfig, launchOptions: launchOptions) { initError in
        if let error = initError {
            switch error {
            /* Hanlde SDK Initialize Error*/
            default: break
            }
        }
    }
}

Breakdown

Let us break down the overall code block into the following:

SDK Authorization

The MoveAuth will look something like this:

let auth = MoveAuth(userToken: "",refreshToken: "" contractID: "", productID: "" )

If the provided MoveAuth was invalid, the SDK will not initialize and complete with MoveConfigurationError.authInvalid. Check Initialization for more details about possible outcomes.

Authentication Expiry

SDK Configuration

MoveConfig allows host apps to configure which of the licensed Move services should be enabled. It could be based on each user preference or set from a remote server.

The MoveConfig will look something like this:

let sdkConfig = MoveConfig(
                timelineDetectionService: [.walking, .driving, .bicycle, .places, 
                .publicTransport],
                drivingServices: [.dfd, .behaviour], 
                otherServices: [.poi])

SDK State

The provided block could then start the SDK when MoveSDKState is ready or handle errors if occurred. The provided block could look something like this:

MoveSDK.shared.setSDKStateListener { state in
    switch state {
    case .uninitialized:
        /* SDK uninitialized*/
        break
    case .ready:
        /* SDK initialised and ready to start the service*/
        MoveSDK.shared.startAutomaticDetection()
    case .running:
        /* SDK Started Detection*/
        break
    case let .error(error):
        switch error {
        /* Hanlde SDK State Errors*/
        default: break
        }
    }
}

SDK Initialization

MoveSDK.shared.initialize(auth: auth, config: sdkConfig, launchOptions: launchOptions) { initError in
    if let error = initError {
        switch error {
        /* Hanlde SDK Initialization MoveConfigurationError*/
        default: break
        }
    }
}

Last updated