React Native
In order for the SDK to start collecting data you would need to perform two steps.
Create a SDK User
Start the SDK
Create User and start the Sentiance SDK
Create a user and start the sentiance SDK. The following should be placed where and when your application is ready to start collecting data (e.g. on user login, on reaching a particular page)
Without User Linking
With User Linking
Please refer to https://docs.sentiance.com/guide/user-linking for documentation on the user linking.
If your backend was unable to link the user to the Sentiance platform, execute
done(false)
instead to notify the SDK that the linking failed
Stopping the Sentiance SDK
Stopping is only allowed after successful initialization. While it's possible to "pause" the detections modules of the Sentiance SDK's, it's not recommended.
Init status
Checking if SDK is initialized
SDK status
The status of the Sentiance SDK
The SDK can signal SDK status updates to JavaScript without being invoked directly. You can subscribe to these status updates by creating a new NativeEventEmitter instance around your module, and adding a listener for SDKStatusUpdate
.
Get SDK version
Get user id
If the SDK is initialized, you can get the user id as follows. This user id will allow you to interact with the API's from Sentiance. You need a token and user to authorize requests and query the right data.
Get user access token
If the SDK is initialized, you can get a user access token as follows. This token will allow you to interact with the API's from Sentiance. You need a token and user to authorize requests and query the right data. If the token has expired, or will expire soon, the SDK will get a new bearer token before passing it to the callback. Generally, this operation will complete instantly by returning a cached bearer token, but if a new token has to be obtained from the Sentiance API, there is a possibility it will fail.
Adding custom metadata
Custom metadata allows you to store text-based key-value user properties into the Sentiance platform. Examples are custom user id's, application related properties you need after the processing, ...
Remove custom metadata
You can remove previously added metadata fields by passing the metadata label to the removeUserMetadataField function.
Adding multiple custom metadata fields
You can add multiple custom metadata fields by passing an object to the addUserMetadataFields function.
Starting trip
Whenever you call startTrip on the SDK, you override moving state detection and the SDK will track the trip until you call stopTrip or until the timeout (2 hours) is reached. startTrip
accepts a metadata object and a transport mode hint (number
) as parameters.
Transport mode hint:
Example:
Stopping trip
The SDK can also signal trip timeouts to JavaScript. You can subscribe to these trip timeouts by creating a new NativeEventEmitter instance around your module, and adding a listener for TripTimeout
.
Trip status
Checking trip status
Control sending data
If you want to override the default behavior, you can initiate a force submission of detections. Ideally, you use this method only after explaining to the user that your app will consume more bandwidth in case the device is not connected to Wi-Fi.
Disk, mobile network and Wi-Fi quotas
The actual usages and limits in bytes can be obtained using the getWiFiQuotaUsage, getWiFiQuotaLimit and similar methods on the Sentiance SDK interface.
All quota functions:
getWiFiQuotaLimit
getWiFiQuotaUsage
getMobileQuotaLimit
getMobileQuotaUsage
getDiskQuotaLimit
getDiskQuotaUsage
User Activity
Get user current activity
The SDK can signal user activity updates to JavaScript without being invoked directly. You can subscribe to these user activity updates by creating a new NativeEventEmitter instance around your module, and adding a listener for SDKUserActivityUpdate
.
Handling user activity
Update SDK foreground notification (ANDROID ONLY)
Updates the title and text of SDK notification. After calling this method, any notification shown by the SDK will be updated.
Note that this change is valid only during the process's lifetime. After the app process restarts, the SDK will display the default notification.
Clearing/Resetting the SDK
To delete the Sentiance user and its data from the device, you can reset the SDK by calling RNSentiance.clear
. This allows you to create a new Sentiance user by reinitializing the SDK, and link it to a new third party ID.
Crash Event Detection(deprecated)
Subscribe to vehicle crash events.
Trip Profiling
Handle on-device trip profiling
Update Trip profiling config
Determine if the app should initialize Sentiance SDK natively
To make user linking possible, the first SDK initialization should be executed in JS. After it completes successfully, await RNSentiance.enableNativeInitialization()
should be invoked.
In AppDelegate (iOS) and MainApplication (Android), isNativeInitializationEnabled
can be used to determine if the SDK should be initialized natively.
To disable native initialization, invoke await RNSentiance.disableNativeInitialization()
.
Please refer to our example app for a complete usage.
Invoke a dummy vehicle crash event
Check if crash detection is supported
Vehicle Crash Event Detection
Listen to vehicle crash events.
Last updated