Quick Start

Getting Started / 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 DolphinMoveSDK
#if canImport(DolphinMoveSDKHealth)
import DolphinMoveSDKHealth
#endif

func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
#if canImport(DolphinMoveSDKHealth)
		sdk.enable(healthKit: MoveSDKHealth.shared)
#endif
    MoveSDK.shared.setSDKStateListener { sdkState in
            switch state {
            case .uninitialized:
                print("/* SDK uninitialized*/")
                break
            case .ready:
                print("/* SDK initialised and ready to start the service*/")
                break
            case .running:
                print("/* SDK Started Detection*/")
                break
            }
    }
    
    MoveSDK.shared.setAuthStateUpdateListener { authState in  ... }    
    MoveSDK.shared.setTripStateListener       { tripState in ... }
    MoveSDK.shared.setServiceFailureListener  { failures in ... }
    MoveSDK.shared.setServiceWarningListener  { warnings in ... }

    MoveSDK.shared.initialize(launchOptions: launchOptions)
}

SDK Authorization and Setup

Users will need to be authenticated. This authentication will persist until shutdown is called. It will persist over the termination of the app. The configuration to enable functionality is passed here. startAutomaticDetection will start the services. This too will persist and services will automatically start when launching the app from the background.

The authentication object is constructed with tokens that need to be acquired from the backend (either from the SDK backend directly, or via your product backend). See MOVE Backend.

Authentication Invalidation

An auth state listener must be implemented to handle user invalidation, which can happen due to a user being blocked or having multiple conflicting installations with the same user.

SDK State

The host app is expected to set its SDKStateListener before initializing the SDK to intercept the MoveSDKState changes.

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:

SDK Initialization

Warnings and Errors

When services are not running properly because they are missing permissions or are not authorized on the backend, warnings or errors will be reported in the corresponding listeners.

WORKING SAMPLE CODE

Last updated