Sentiance
The Sentiance class is the main entry point for interacting with the SDK.
shared
The Singleton instance to get the shared instance of the SDK.
Usage: Sentiance.shared
sdkStatus
Get SDK status information
initState
Return state of initialisation of the SDK: SENTNotInitialized, SENTInitInProgress, SENTInitialized.
detectionStatus
Get current detection status.
userActivity
SDK current user activity state. It is a trip or stationary with some enriched information.
criteriaMaskForUserContextUpdates
The criteria for which the delegate property userContextDelegate
will get invoked.
userContextDelegate
Delegate property which gets notified when the userContext is updated
smartGeofenceEventsDelegate
Delegate property which gets notified when Smart Geofence events are detected
version
SDK Version property
userId
Returns the user ID.
userExists
Checks if a Sentiance user exists on the device. You may call this method without having initialized the SDK. Returns true if a Sentiance user exists.
isUserLinked
Checks if a Sentiance user exists on the device, and whether it is linked to your app's user. You may call this method without having initialized the SDK. Returns true if a Sentiance user exists and is linked.
isVehicleCrashDetectionSupported
Checks if vehicle crash detection is supported on the device. The result depends on multiple criteria, such as if vehicle crash detection is enabled for your app, and if the necessary sensors are present on the device.
wifiQuotaLimit
SDK WiFi quota limit
wifiQuotaUsage
SDK WiFi quota usage
mobileQuotaLimit
SDK mobile data quota limit
mobileQuotaUsage
Get SDK mobile data quota usage
diskQuotaLimit
SDK disk quota limit
diskQuotaUsage
SDK disk quota usage
drivingInsightsProcessedDelegate
Sets a delegate that will be invoked when the driving insights for a completed transport becomes ready. Set nil
to remove a previously set delegate.
Note: setting or accessing this delegate on an uninitialized SDK will throw an NSException.
eventTimelineDelegate
A delegate that will be invoked when the event timeline is updated.
An update can be triggered by the start of a new event, and the update or end of an existing one. Every invocation will deliver an event that has a lastUpdateDate
that is equal to or greater than the previously delivered event's lastUpdateDate
.
You can use this delegate along with getTimelineUpdatesAfter: to stay up to date with the latest events in the timeline. For example, to make sure you don't miss out on timeline updates, you can first set this delegate, then follow up by calling getTimelineUpdatesAfter: to query for potential updates since the last update you received.
Note: setting or accessing this delegate on an uninitialized SDK will throw an NSException.
allowedToUseMobileData
Sets or returns whether the Sentiance SDK is allowed to use mobile data for uploading and downloading configuration and detection data. This setting applies to most types of data transfers done by the SDK, with the exception of a few lightweight data payloads.
The setting is persisted across app restarts, but is reset to a default value of true when the SDK is reset.
Note: setting or accessing this delegate on an uninitialized SDK will throw an NSException.
initWithConfig: success: failure:
Deprecated
This method is deprecated. Use initializeWithOptions: launchOptions: instead.
SDK initialization method. It sets up the modules internally and handles user authentication.
config
The configuration used to authenticate the user.
success
The success block called when init succeeded.
failure
The failure block called when init failed. It takes a SENTInitIssue issue indicating the reason of the failure.
Init should only be called once, unless initialization fails.
initializeWithOptions: launchOptions:
Initializes the Sentiance SDK.
This method must be called on the main thread, inside
It must not be called asynchronously, as doing so does not guarantee that it will be invoked before application:didFinishLaunchingWithOptions:
completes.
For more details on this, see SDK Initialization.
Most SDK methods require an initialized SDK before being invoked, otherwise they throw a runtime exception. Methods excluded from this requirement mention this in their respective documentation.
You should initialize the SDK at most once, during app startup. Initializing it multiple times will normally fail with reason SENTInitializationFailureReasonReinitializationNotAllowed
unless a user does not exist yet (e.g. before user creation or after an SDK reset), in which case multiple initializations are still allowed.
options
the SDK initialization options.
launchOptions
the launch options obtained from [AppDelegate application:application didFinishLaunchingWithOptions:launchOptions]
start:
Deprecated
This method is deprecated. Use enableDetectionsWithCompletionHandler: instead.
Start the SDK.
completion
The completion block called when the SDK has started. SENTSDKStatus object indicates any issue that occurred when the SDK started.
start should be called only after the SDK has been successfully initialized.
startWithStopDate: completion:
Deprecated
This method is deprecated. Use enableDetectionsWithExpiryDate: completionHandler: instead.
Start the SDK with expiration date.
sdkStopDate
Should be set with date in the future. Dates in past will cause imediate stop of SDK. Setting nil will start SDK as usual.
completion
The completion block called when the SDK has started. SENTSDKStatus object indicates any issue that occurred when the SDK started.
stop
Deprecated
This method is deprecated. Use disableDetectionsWithCompletionHandler: instead.
Stop the SDK.
enableDetectionsWithCompletionHandler:
Enables SDK detections.
Requires a Sentiance user to be present on the device. Enabling detections is persistent across app restarts. Therefore, you do not need to call this method on every app startup. Once detections are enabled, as long as the SDK is properly initialized during startup, detections will be resumed, until you disable them by calling disableDetections.
Enabling detections does not mean that the SDK is successfully able to start all detections. There may be unsatisfactory conditions that are blocking some detections. Check the DetectionStatus returned in the result to see if all detections are running and the SdkStatus to identify possible causes if not.
To automatically disable detections after some time, use the enableDetectionsWithExpiryDate: variant of this method.
Note: calling this method on an uninitialized SDK will throw an NSException.
enableDetectionsWithExpiryDate: completionHandler:
Enables SDK Detections with an expiry date at which detections get disabled.
Requires a Sentiance user to be present on the device. Enabling detections is persistent across app restarts. Therefore, you do not need to call this method on every app startup. Once detections are enabled, as long as the SDK is properly initialized during startup, detections will be resumed, until you disable them by calling disableDetections(), or they expire (see expirationDate).
Enabling detections does not mean that the SDK is successfully able to start all detections. There may be unsatisfactory conditions that are blocking some detections. Check the DetectionStatus returned in the result to see if all detections are running, and the sdkStatus to identify possible causes if not.
This method has the same behaviour as enableDetections:, except an expiration date can be specified, as an absolute Date object, to automatically disable detections some time in the future. After having called this method with a future expiration date, you can cancel the expiration any time by calling enableDetections: again.
disableDetectionsWithCompletionHandler:
Disables SDK detections.
Currently, this operation always succeeds. However, this behaviour may change in the future.
Also throws NSException – if the SDK is not initialized.
createUserWithOptions: completionHandler:
Creates a Sentiance user if one does not yet exist.
Most SDK functionality requires a Sentiance user to be present on the device. Therefore, create a user first before enabling detections or interacting with other SDK features.
Parameter: Options
- For creating a User.
Throws: NSException if the SDK is not initialized.
linkUserWithLinker: completionHandler:
Links the Sentiance user to your app's user on the Sentiance Platform.
During the linking process, the SDK will invoke the supplied SENTUserLinker, and will pass to it an installation ID. Your app must then forward this installation ID to the Sentiance backend (via your backend), and initiate user linking. Finally, when the linking completes, you must invoke the proper linker callback to complete the process.
Here are the complete steps:
Call this method and supply a linker.
Your linker will be invoked during the process, and an installation ID will be supplied.
In your linker, forward the installation ID to your backend to initiate a linking request towards the Sentiance backend. This request will include the installation ID and your app's user identifier.
Retrieve the response from the Sentiance backend and forward the result to the app.
Based on the result, invoke the linker callback's success or failure method. The callback is supplied to your linker along with the installation ID.
If it was successful, the SDK will confirm the result with the Sentiance backend to complete the link.
This method is useful if you want to link a Sentiance user that was created without specifying a linker in the user creation options (thereby having created an unlinked user).
With this method, a Sentiance user cannot be linked to an app user that already exists on the Sentiance Platform (i.e. with an app user identifier that you already supplied to Sentiance during a past linking request).
You can only link to an app user that is new to Sentiance. This is because an existing app user will already have a corresponding Sentiance user on the platform, and that Sentiance user cannot be restored here anymore. To restore that user, you must reset the SDK and recreate a linked Sentiance user instead.
parameter: linker: the linker that the SDK will pass the installation ID to and execute success and failure closures according to result.
throws: NSException if the SDK is not initialized.
linkUserWithAuthCode: completionHandler:
Links the Sentiance user to your app's user on the Sentiance Platform.
Uses the supplied authentication code to find the app user. Therefore, before calling this method, make sure that you have obtained a valid code from the backend Sentiance API (thereby having initiated the first linking step). This code request is authenticated using a Sentiance API key, which must never be transmitted to the app. Hence why the request must come from your backend.
Here are the complete steps:
Retrieve the code in your app and supply it to this method.
Initiate an authentication code request via your backend towards the Sentiance backend. This request will include your app's user identifier, which will be temporarily coupled to the code that you will receive.
The SDK will forward the code to the Sentiance backend to complete the link.
This method is useful if you want to link a Sentiance user that was previously created without specifying a linker in the user creation options (thereby having created an unlinked user).
With this method, a Sentiance user cannot be linked to an app user that already exists on the Sentiance Platform (i.e. with an app user identifier that you already supplied to Sentiance during a past authentication code request). You can only link to an app user that is new to Sentiance.
This is because an existing app user will already have a corresponding Sentiance user on the platform, and that Sentiance user cannot be restored here anymore. To restore that user, you must reset the SDK and recreate a linked Sentiance user instead.
parameters: authCode - a code obtained from the backend Sentiance API.
throws: NSException if the SDK is not initialized.
requestUserAccessTokenWithCompletionHandler:
Returns the user's API access token as a Token object, via the completion Handler.
The token might be refreshed during this call, in which case, a valid network connection is required. You can use this token to query the Sentiance API for the user's data.
throws: NSException if the SDK is not initialized.
requestUserContextWithCompletionHandler:
Fetches the userContext which holds the information about events, activeMoments, activeSegments, lastKnownLocation, home and work venues.
getUserId
Deprecated
getUserId
is deprecated. Use userId instead.
Returns the user ID
getUserAccessToken:
Deprecated
getUserAccessToken
is deprecated. Use requestUserAccessToken instead.
Returns the users Access Token if the user is authenticated
addUserMetadataField: value:
Interface method to set metadata for user. Metadata is any additional data that enclosing app is willing to set for this user/app combination This metadata could contain vital information related to procesing wrt to the enclosing app.
label
Field name for the new entry.
value
Value for the new entry.
addUserMetadataFields:
Interface method to set metadata for user. Metadata is any additional data that enclosing app is willing to set for this user/app combination This metadata could contain vital information related to processing wrt to the enclosing app.
metadata
Key value pair data from enclosing app, could have any structure as long as it can be contained in a dictionary.
removeUserMetadataField:
Method to remove user data field to the sdk metadata (locally as well as on backend).
label
Field name for the new entry.
addTripMetadata:
add metadata pertaining to the ongoing external trip. All added metadata will be aggregated and added to the trip payload. Returns NO if there's no ongoing external trip.
metadata
key value pair data from enclosing app, could have any structure as long as it can be contained in a dictionary. The only time we return NO is when a trip is not ongoing, metadata contains NSNull objects or nil itself.
startTripWithMetadata: transportModeHint: completionHandler:
Starts an external trip. Requires a Sentiance user to be present on the device.
Calling this method interrupts any ongoing SDK detection, and forces the SDK to stay in a data collection mode. Trips started with this method may time out, in which case, the TripTimeoutListener set using setTripTimeoutListener(TripTimeoutListener) will be invoked.
The timeout duration can be configured for your app by Sentiance.
parameters:
metadata - A map of metadata pertaining to the newly started trip, which will be saved along with
the trip data, and made available in backend API query results and offloads. May be null.
mode - A hint of the transport mode being used, if known. May be <code>null</code>.
throws: NSException if the SDK is not initialized.
startTrip: transportModeHint: success: failure:
Deprecated
This method is deprecated. Use startTripWithMetadata: transportModeHint: completionHandler: instead.
Start a Trip manually
metadata
Key value pair data from enclosing app, could have any structure as long as it can be contained in a dictionary.
transportModeHint
Suggest of transport mode
stopTrip: failure:
Deprecated
This method is deprecated. Use stopTripWithCompletionHandler: instead.
Stop a trip.
stopTripWithCompletionHandler:
Stops the currently ongoing external trip (i.e one that was started by calling startTrip()
Throws: NSException if the SDK is not initialized.
setTripTimeOutListener:
Set a trip timeout block.
tripDidTimeOut block will be called each time trip will time out
isVehicleCrashDetectionSupported:
Checks if vehicle crash detection is supported on the device for the specified trip type.
The result depends on multiple criteria, such as if vehicle crash detection is enabled for your app, and if the necessary sensors are present on the device.
tripType
The type of trip for which you want to check
invokeDummyVehicleCrash
Invokes a dummy vehicle crash event. Use this method to test your vehicle crash detection integration.
Calling this method will invoke the handler from setVehicleCrashHandler:
or setCrashListener:
depending on which handler was set last.
This method is intended for testing your integration, and not for production use.
setCrashListener:
Deprecated
setCrashListener:
is deprecated. Use setVehicleCrashHandler:
instead.
Set vehicle crash detection block.
setVehicleCrashHandler:
Sets a handler that is invoked when a vehicle crash is detected with an instance of SENTVehicleCrashEvent
.
setUserActivityListener:
This method provides the enclosing app the ability to get SDK detection updates. So when the SDK is in a trip or a stationary, it informs the app via a callback, providing some extra information.
getUserActivity
This method provides the enclosing app the ability to get SDK current user activity state. It is a trip or stationary with some enriched information.
isTripOngoing:
Interface method to check if trip is in progress or not.
tripType
Type of ongoing trip, SDK - started by SDK, External - started by the application
submitDetections: failure:
Deprecated
This method is deprecated. Use submitDetectionsWithCompletionHandler: instead.
Submits all the pending detections to backend, without considering any quota related updates and returns the status of these submissions via a callback to the enclosing app.
success
Success block which is to be called when forced submission completes.
failure
Failure block which is to be called when forced submission completes.
submitDetectionsWithCompletionHandler:
Submits any pending SDK detection to the Sentiance API.
This method will bypass any network quota limitation set for the SDK. A typical use case would be when the enclosing app determines (via diskQuotaUsage or diskQuotaStatus) that there are too many detections on disk that have not yet been submitted.
Throws: NSException if the SDK is not initialized.
getInitState
Deprecated
This method is deprecated. Use initState property instead.
Return state of inialization of the SDK: SENTNotInitialized, SENTInitInProgress, SENTInitialized
getSdkStatus
Deprecated
Use sdkStatus property instead.
Get SDK status information
getVersion
Deprecated
Use version property instead.
Get SDK version
getWifiQuotaLimit
Deprecated
Use wifiQuotaLimit:
property instead.
Get SDK WiFi quota limit
getWiFiQuotaUsage
Deprecated
Use wifiQuotaUsage property instead.
Get SDK WiFi quota usage
getMobileQuotaLimit
Deprecated
Use mobileQuotaLimit
instead.
Get SDK mobile data quota limit
getMobileQuotaUsage
Deprecated
Use mobileQuotaUsage instead.
Get SDK mobile data quota usage
getDiskQuotaLimit
Deprecated
Use diskQuotaLimit property instead.
Get SDK disk quota limit
getDiskQuotaUsage
Deprecated
Use diskQuotaUsage: instead.
Get SDK disk quota usage
resetWithCompletionHandler:
The reset functionality is intended for removing all data in the device to handle a case such as a different user logging into an app, or a user requesting data deletion in the local app. It should not be used for disabling SDK detections, or for logging out a user (if the same user is expected to log in again in the near future).
Resets the Sentiance SDK.
Calling this method results in stopping of all SDK operations and the deletion of all user data from the device. To avoid losing unsubmitted detection data, you can call submitDetections() before resetting the SDK as a final (best effort) attempt. However, keep in mind that this can introduce a delay to your reset process, since it is impacted by the network capability and the number of pending detections.
During an ongoing reset operation, calling any other SDK method will be ignored, fail, or will return a default result. After the reset operation completes, you do not have to reinitialize the SDK, but can do so by calling initialize(SentianceOptions)} again (e.g. to supply a different SentianceOptions).
While resetting, make sure that your app is in the foreground to prevent process termination (i.e. an activity is open, or a foreground service is running). The SDK cannot guarantee the completion of this operation otherwise.
You may call this method without having initialized the SDK.
completionHandler
a completion handler to receive the result of the reset operation.
reset: failure:
Deprecated
Use resetWithCompletionHandler**:** instead.
The reset functionality is intended for removing all data in the device to handle a case such as a user logging out from an app or user requesting data deletion in the local app. It should not be used to reset the internal state of the SDK.
Resets the Sentiance SDK. Calling this method results in stopping of all SDK operations and deleting all SDK user data from the device. Additionally, the SDK will be uninitialized, allowing reinitialization and new Sentiance user creation.
The reset operation may take a while, in which case the SDK's initialization state will be set to InitState SENTResetting until it is complete. Calling any other SDK method during this time will either be ignored or return a default value.
Note that calling this method during intermediate initialization states (i.e. InitState SENTInitInProgress} and InitState SENTResetting will fail.
success
Success block callback when reset successfully done
failure
Failure callback when with one of SENTResetFailureReason happened
setDidReceiveSdkStatusUpdateHandler:
Sets a handler that is invoked when the SDK's status is updated.
handler
a handler to receive SDK status updates, or nil to remove the previously set handler.
setVehicleCrashDiagnosticHandler:
Sets a handler that is invoked when a vehicle crash diagnostic is detected.
vehicleCrashDiagnosticHandler
a handler to receive vehicle crash diagnostics of type SENTVehicleCrashDiagnostic
throws: NSException if the SDK is not initialized.
setTransmittableDataTypes:
Set the data types that are allowed to be sent to the Sentiance Cloud Platform.
This configuration is persistent across app restarts, but will be cleared upon SDK reset.
Note: this configuration is not applicable to logging and diagnostic data that may get uploaded to the Sentiance Cloud Platform (if enabled for your app).
transmittableDataTypes
data types of type SENTTransmittableDataType.
throws: NSException if the SDK is not initialized.
transmittableDataTypes
Returns a set of SENTTransmittableDataType data types that are allowed to be sent to the Sentiance Cloud Platform.
throws: NSException if the SDK is not initialized.
enableTransportSessionRecording
enableTransportSessionRecording
Enables transport session recording.
This setting is persistent across app restarts, so you only need to enable session recording once. Note however that the setting is reset to disabled
after an SDK reset. See reset.
Recorded sessions are stored on the device until the time that you request their deletion. See deleteTransportSession(String)
.
Note: calling this method on an uninitialized SDK will throw an NSException.
disableTransportSessionRecording
Disables transport session recording.
This setting is persistent across app restarts, so you only need to disable session recording once.
If you no longer need session recording, make sure to delete previously recorded sessions if you no longer need them. See deleteAllTransportSessions()
.
Note: calling this method on an uninitialized SDK will throw an NSException.
getAvailableTransportSessions
Returns a list of recorded and completed transport sessions.
Note: calling this method on an uninitialized SDK will throw an NSException.
isTransportSessionRecordingEnabled
Returns whether transport session recording is enabled.
Note: calling this method on an uninitialized SDK will throw an NSException.
setTransportSessionHandler:
Sets a handler that will be invoked to deliver transport sessions. A session is delivered after a transport ends.
Transport sessions are stored on the device until the time that you request their deletion. See deleteTransportSession(String)
.
Note: calling this method on an uninitialized SDK will throw an NSException.
transportSessionHandler
A transportSessionHandler to receive transport sessions, or nil
to remove a previously set handler.
deleteAllTransportSessions
Deletes all recorded transport sessions.
Recorded sessions are stored on the device. It is your responsibility to call this method, or deleteTransportSession(String)
, to request their deletion, when you no longer need them.
Note: calling this method on an uninitialized SDK will throw an NSException.
deleteTransportSession:
Deletes the transport session with the specified ID.
Recorded sessions are stored on the device. It is your responsibility to call this method, or deleteAllTransportSessions
, to request their deletion, when you no longer need them.
Note: calling this method on an uninitialized SDK will throw an NSException.
sessionId
The ID of the session to delete.
getDrivingInsightsForTransportId:
Returns the driving insights for a given transport, or nil
if there are no driving insights or the transport ID is invalid.
Note: calling this method on an uninitialized SDK will throw an NSException.
transportId
The ID of the desired transport.
getHarshDrivingEventsForTransportId:
Returns the harsh driving events for a completed transport.
Note: calling this method on an uninitialized SDK will throw an NSException.
transportId
The ID of the desired transport.
getPhoneUsageEventsForTransportId:
Returns the phone usage events for a completed transport.
Note: calling this method on an uninitialized SDK will throw an NSException.
transportId
The ID of the desired transport.
getCallWhileMovingEventsForTransportId:
Returns the call while moving events for a completed transport.
Note: calling this method on an uninitialized SDK will throw an NSException.
transportId
The ID of the desired transport.
getSpeedingEventsForTransportId:
Returns the speeding events for a completed transport.
Note: calling this method on an uninitialized SDK will throw an NSException.
transportId
The ID of the desired transport.
getTimelineEventWithEventId:
Returns the timeline event with the specified ID, or nil
if no such event exists.
Note: calling this method on an uninitialized SDK will throw an NSException.
eventId
The ID of the desired timeline event.
getTimelineEventsFrom: to:
Returns timeline events, such as transport and stationary events, that were captured during the specified date range. The events are ordered from oldest to newest.
Events that were captured outside of the specified date range are not returned, even if they were updated during this date range. To get all updates, regardless of when an event was captured, use getTimelineUpdatesAfter: instead.
Note: calling this method on an uninitialized SDK will throw an NSException.
dateFrom
The start date of the date range. The specified date is inclusive.
dateTo
The end date of the date range. The specified date is inclusive.
getTimelineUpdatesAfter:
Returns all updated events in the event timeline after the specified date, sorted by the last update time.
This method returns all events that started after the date, but it may also return events that started before the date, if they were updated afterwards. The returned result is not necessarily the complete list of events that were captured by the SDK from the result's first event until the last, because events that were not updated will be excluded. To get a complete and ordered list of events for a given date range, use getTimelineEventsFrom:to: instead.
You can use this method along with eventTimelineDelegate to stay up to date with the latest events in the timeline. For example, to make sure you don't miss out on timeline updates, you can first set the delegate, then follow up by using this method to query for potential updates since the last update you received.
Note: calling this method on an uninitialized SDK will throw an NSException.
date
The date to retrieve updates from. The specified date is exclusive.
smartGeofenceDetectionMode
Returns the geofence entry/exit detection mode. See SmartGeofenceDetectionMode.
Note: calling this method on an uninitialized SDK will throw an NSException.
refreshSmartGeofencesWithCompletionHandler:
Refreshes the list of geofences that the SDK monitors.
The SDK obtains the list of geofences that it monitors from the Sentiance Cloud Platform, and refreshes it several times a day. Use this method to initiate a refresh, for instance, when you have created a new geofence directly on the Sentiance Platform, and want it to be immediately monitored by the SDK. Note that refresh requests are throttled to once every 30 seconds.
Note: calling this method on an uninitialized SDK will throw an NSException.
handler
The handler to to receive geofence refresh result / error. See SENTSmartGeofencesRefreshHandler.
Last updated