Mobility Insights
Prerequisites
The Mobility 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 Event Timeline APIs
In this section, you can find examples of how to query the Sentiance SDK for historic timeline events (e.g. transports and stationaries), and how to register to receive timeline updates in your app, as new events are detected or existing ones are updated.
Query for Historic Events
You can query for past events in the user's timeline by utilizing the getTimelineEvents method.
Subscribe for and Retrieve Event Timeline Updates
To receive event updates, such as when a transport starts or ends, you can subscribe for event timeline updates.
The example below demonstrates a robust approach to collecting timeline events by combining an event update subscription with a query for updates since the last processed event. This ensures the logic remains resilient to interruptions or unexpected app terminations.
To get event timeline 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 according to 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