Services
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 should be in.ready
MoveSDKState
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 should be in.running
MoveSDKState.
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 should 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()
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
Return
Latest SDK State
Set SDK State Listener
Provide a block to be invoked every time MoveSDKState changes.
func setSDKStateListener(listener: SDKStateCallback)
func setSDKStateListener(_ listener: SDKStateCallback)
Callback
Block that gets invoked every time MoveSDKState is changed and provides the updated MoveSDKState.
Get SDK Auth State
Gets the current MoveAuthState.
func getAuthState() -> MoveAuthState
Return
Latest SDK State
Set SDK Auth State Listener
Provide a block to be invoked every time MoveAuthState changes.
func setAuthStateUpdateListener(listener: AuthStateCallback)
func setAuthStateUpdateListener(_ listener: AuthStateCallback)
Callback
Block that gets invoked every time MoveAuthState is updated.
Authentication Expiry
The host app is expected to monitor MoveAuthState updates viaauthStateUpdateListener
(Android / iOS) API and handle those changes accordingly.
Check Authentication updates and expiry for more details about authentication expiry and renewal.
Get Trip State
Gets the current MoveTripState.
func getTripState() -> MoveTripState
Return
Current MoveTripState
Set Trip State Listener
Provide a block to be invoked every time MoveTripState changes.
func setTripStateListener(listener: TripStateCallback)
func setTripStateListener(_ listener: TripStateCallback)
Callback
Block that gets invoked every time MoveTripState is changed and provides the updated MoveTripState.
Get Device Status
Gets the current MoveDeviceStatus.
func getDeviceStatus() -> MoveDeviceStatus
Return
Current MoveDeviceStatus
Set Device Status Listener
Provide a block to be invoked every time MoveDeviceStatus changes.
func setDeviceStatusListener(listener: DeviceStatusCallback)
func setDeviceStatusListener(_ listener: DeviceStatusCallback)
Callback
Block that gets invoked every time MoveDeviceStatus is changed and provides the updated MoveDeviceStatus.
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. Böuetooth 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 product.
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)
func setTripMetaDataListener(_ listener: MetaDataCallback)
Callback
Block that gets invoked on every trip finish. The block provides the trip's start and stop times.
Usage Example
MoveSDK.shared.setMetadataListener{ (tripStartTime, tripEndTime)
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)
func setLogListener(_ listener: LogCallback)
Callback
Block that gets invoked with every new log event.
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)
Parameter
enabled
Boolean that sets SDK console logging to enabled or not.
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()
Shutdown SDK
Shutdown SDK shared instance.
Stops SDK services, send the queued user data, and de-initializes the SDK. After that is executed, the MoveSDKState will transit to .uninitialized
.
Precondition: SDK should be initialized.
func shutDown()
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.
Configuration services
Update authentication
Updates SDK MoveAuth. On SDK auth expiry, the Builder.authStateListner will trigger expired state. The host app is expected to fetch a new MoveAuth using its product API key and pass it to the MoveSDK using the following API:
func update(auth: MoveAuth, completion: ((MoveConfigurationError?) -> Void)? = nil)
Parameter
auth
The user's updated Auth object with the new token.
Callback
completion
Block that gets invoked on auth update completion with an optional MoveConfigurationError for potential updating errors.
Last updated