Services

API Interface / iOS

Shared Instance

Use the shared instance as your interface to the MOVE SDK.

static let shared: MoveSDK

Detection Services

Start Automatic Detection

Starts the required detection services stated in the MoveConfig passed on initialization. Starting the service will set the MoveSDKState to .running.

Precondition: SDK must be in.readyMoveSDKState

func startAutomaticDetection()

Stop Automatic Detection

Stops the automatic detection service, including all SDK services like driving detection, points of interest, walking and places. Stopping the service will set the MoveSDKState back to .ready.

Precondition: SDK must be in.runningMoveSDKState.

func stopAutomaticDetection()

Force Trip Recognition

Temporarily calibrates the SDK to the highest detection mode.

In order to optimize battery consumption, the SDK goes through different detection modes with different battery consumption levels, depending on the user's current behavior and activity. In general, the SDK is responsible for alternating between those different detection modes.

The SDK also provides hosting apps this API to call if they have their own reasons (like buttons, sensors or beacons) to believe that the user is starting a trip. This will make sure the SDK is on the highest detection state to detect the trip faster.

Precondition: SDK must be in.running MoveSDKState.

func forceTripRecognition()

Finish Current Trip

Ends the current ongoing trip.

This API will end the ongoing trip and set MoveTripState back to .idle. The SDK is responsible for detecting the trip start and end points. The SDK also provides hosting apps this API to call if they have their own reasons (like sensors or beacons) to believe that the user's trip has ended.

Precondition: MoveTripState should be in an active trip.

func finishCurrentTrip()

If this API is called while the user is active on a driving trip, a new trip will start again right away. If the intention is to un-track the ongoing trip, call ignoreCurrentTripAPI.

More information about trip states can be found in MoveTripState.

Ignore Current Trip

Ignores the current ongoing trip.

This API will set the ongoing MoveTripState to .ignored. Data of ignored trips is purged and not sent to the server.

Precondition: MoveTripState should be in an active trip.

func ignoreCurrentTrip()

Processing Services

Get SDK State

Gets the current MoveSDKState.

func getSDKState() -> MoveSDKState

Set SDK State Listener

Provide a block to be invoked every time MoveSDKState changes.

Set the MoveSDKState listener before initializing the SDK to anticipate the SDK State changes triggered by the initialization API. Here the host app can start the SDK services when MoveSDKState is.ready.

func setSDKStateListener(_ listener: SDKStateCallback)

Get Trip State

Gets the current MoveTripState.

func getTripState() -> MoveTripState

Set Trip State Listener

Provide a block to be invoked every time MoveTripState changes.

func setTripStateListener(_ listener: TripStateCallback)

Get Device Status

Gets the current MoveDeviceStatus.

func getDeviceStatus() -> MoveDeviceStatus

Get Service Failures

Gets the current MoveServiceFailures.

func getServiceFailures() -> [MoveServiceFailure]

Set Service Failure Listener

func setServiceFailureListener(_ listener: @escaping MoveServiceFailureCallback)

Provide a block to be invoked every time MoveServiceFailures change.

Get Service Warnings

Gets the current MoveServiceWarnings.

func getServiceWarnings() -> [MoveServiceWarning]

Set Service Warning Listener

Provide a block to be invoked every time MoveServiceWarnings change.

func setServiceWarningListener(_ listener: @escaping MoveServiceWarningCallback)

Set Metadata Listener

Provide a block returning bundle of key-value pairs to be appended to the trip metadata before the trip finishes.

Host apps can use this API to add any app-level information (for ex. Bluetooth beacon detected, foreground/background time, etc) to append to a trip as metadata. This metadata will be forwarded back along with the trip when fetched by the client-server, so the host app can utilize it in its app. Note: The SDK will not use this metadata element in any way, it is just passed through to the project environment.

The block provides the trip's start and stop times. Make sure to only include metadata events that are relevant for the given start and end periods.

func setTripMetaDataListener(_ listener: MetaDataCallback)

Usage Example

MoveSDK.shared.setMetadataListener{ (tripStartTime, tripEndTime) in
    getCollectedMetadataForPeriod(start: tripStartTime, end: tripEndTime)
}

Set Log Listener

Provide a block to be invoked every time a new SDK log event occurs.

func setLogListener(_ listener: LogCallback)

Set Console Logging State

Toggles console logging enabled state.

This doesn't affect recieving the logs via setLogListener(_ listener: MoveLogCallback) API.

Enabled by default.

func setConsoleLogging(enabled: Bool) 

Geocoding

Geo-coordinate address lookup.

func geocode(latitude: Double, longitude: Double, completion: @escaping (Result<String, MoveGeocodeError>) -> Void)

Geocode will use Apple's builtin CLGeocoder.reverseGeocodeLocation or fallback to contacting the MOVE backend to attempt a geo-lookup.

Throttle: Geocode is limited to a maximum of 100 lookups per hour.

CLGeocoder.reverseGeocodeLocation has its own throttling and maybe used up for the app calling this function.

Delete Local Data

Deletes all the collected user SDK data stored on the device. This doesn't affect the MoveSDKState.

Precondition: MoveSDKState should be initialized.

func deleteLocalData()

Synchronize User Data

Used to force synchronizing user data with the SDK server. Limited to once per 2 minutes.

func synchronizeUserData()

Returns FALSE in case there are Timeline-relevant packages in the queue that remain to be sent to the SDK Backend; and it returns TRUE in case the queue is empty.

Other Services

Initiate Assistance Call

New feature in MOVE SDK 2.x; configuration in MOVE dashboard pending - please get in touch.

Initiate an assistance call to emergency services.

func initiateAssistanceCall(_ completionHandler: @escaping (MoveAssistanceCallStatus) -> Void)

The application should process the callback status and inform the user in case of failure.

Precondition: The assistance call service needs to be configured in the MOVE dashboard. The SDK needs to be in ready or running state.

Set Assistance MetaData

New feature in MOVE SDK 2.1

func setAssistanceMetaData(_ metadata: String)

The metadata string is sent to the server with each manual assistance call and with each AID report. The contents of the string can be anything, e.g. JSON data. The assistance data is persisted once set.

Get Device Qualifier

New feature in MOVE SDK 2.2

Get a unique qualifier to identify the individual device.

func getDeviceQualifier() -> String

The device qualifier should be passed to the backend during user registration and user token update. See Move backend.

Last updated

#70: add MoveSdkAndroidConfig model

Change request updated