via On Device API

Access to the On Device Sentiance Insights is available through the APIs exposed by the Sentiance SDK (iOS, Android, React Native and Flutter) .

Available Insights

The On Device API provides access to following insights:

  • Driving Insights

  • Mobility Insights

  • Lifestyle Insights

Fetching Insights

Depending on your use-case and the technical design of your application, you have two options to retrieve insights:

  1. Querying the SDK on Demand

  2. Listening to Callbacks for Real-time Updates

Querying the SDK on Demand

You can query the SDK for insights at any point in your application codebase. The following example demonstrates how to fetch the recent trips:

let currentDate = Date()
let calendar = Calendar.current
let fiveDaysAgo = .day, value: -5, to: currentDate)

let events = Sentiance.shared.getTimelineEvents(from: fiveDaysAgo!, to: currentDate)
events.forEach { event in

Similarly, you can request various insights. Read through the full example and explore SDK API Reference for a comprehensive list of available APIs

Listening to Callbacks for Real-time Updates

When setting up callbacks for real-time updates, it's crucial to ensure that you attach the listener at the appropriate location in your code.

The listeners should be included in the app boot-up scripts, right after executing the SDK initialization commands.

Below is an example of how to listen to TimelineEvent updates in real-time:

//  AppDelegate.swift

import SENTSDK
import UIKit


class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {        
        initializeSentianceSDK(launchOptions: launchOptions)
        return true
    private func initializeSentianceSDK(launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
        let options = SENTOptions(for: .appLaunch)
        let initializationResult = Sentiance.shared.initialize(options: options, launchOptions: launchOptions)     
        Sentiance.shared.eventTimelineDelegate = EventTimelineUpdateReceiver.shared // <-------


// EventTimelineUpdateReceiver.swift
class EventTimelineUpdateReceiver : EventTimelineDelegate {
    static let shared = EventTimelineUpdateReceiver()
    func onEventTimelineUpdate(event: SENTTimelineEvent) {

Synchronising Insights with Your Backend

A common practice when utilizing On-Device Insights involves ensuring the insights are effectively synchronised with your backend storage systems. This step is essential for integrating real-time data insights directly into your data management workflows.

Deciding on the optimal placement of listeners is crucial for syncing data with your backend, based on whether the application is in the foreground or background. This ensures that the insights remain accessible to the underlying systems at all times.

For background syncing, place listeners in startup scripts to activate when the app is woken by the OS. For foreground syncing, integrate listeners either in startup scripts or in specific startup functions as the user begins their session, ensuring seamless data sync with your backend in all app states.

Insert the listeners within AppDelegate.swift file just following the Sentiance.shared.initialize initiation step. This placement ensures they are primed to manage background processes as soon as the application initiates.

Additional helpful links:

Last updated