Lifestyle Insights
Prerequisites
The Lifestyle Insights feature relies on additional library dependencies alongside the core SDK dependency. To start using this feature, you must first add these dependencies to you project.
Utilize the User Context APIs
In this section, you can find examples of how to query the Sentiance SDK for the user's current context, and how to register to receive context updates in your app, as the user's context changes.
Query for the User's Current Context
The user's context includes the following information:
Recent transport and stationary events, with venue information if available.
The user's last known location.
The user's home and work locations, if detected.
The user's current semantic time (e.g. morning time, lunch time).
The user's segments, if detected (e.g. dog walker, aggressive driver).
The population of this context information happens offline, on the device.
Subscribe for User Context Updates
You can subscribe to receive updates, as the user's current context changes.
To get user context updates even when your app is in the background, place the following code inside your app's entrypoint index.js file. If you're only interested in these updates when your app is foregrounded, place this code inside the appropriate UI code instead.
Create a background.dart file under your project's lib folder with the following code:
Add the following code, depending on your target platform.
For iOS, add the following to your app delegate class:
For Android, add this code to your custom application class:
Last updated