Lifestyle Insights
To learn about the Lifestyle Insights feature, check out this page.
This feature is currently in Early Access and is still under active development
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.
Android
Open your app build.gradle file and add the lifestyle dependency.
dependencies {
implementation(platform('com.sentiance:sdk-bom:<sentiance-version>'))
implementation("com.sentiance:sdk-lifestyle")
}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
Checkout Real-time Listeners to read more about implementing the SDK's Listeners
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:
If you're calling other 3rd party plugin APIs inside your registerUserContextListener Dart function, then you need to register these plugins with the Sentiance SDK. See this for more details.
Last updated