SDK APIs
Sentiance Insights is available through the APIs exposed by the Sentiance SDK for:
iOS
Android
React Native
Flutter
Fetching Insights
Depending on your use-case and the technical design of your application, you have two options to retrieve insights:
Querying the SDK on Demand
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 logic. The following example demonstrates how to fetch the recent timeline events:
let currentDate = Date()
let calendar = Calendar.current
let fiveDaysAgo = calendar.date(byAdding: .day, value: -5, to: currentDate)
let events = Sentiance.shared.getTimelineEvents(from: fiveDaysAgo!, to: currentDate)
events.forEach { event in
print(event.eventId)
}val from = Date(0)
val to = Date(Long.MAX_VALUE)
EventTimelineApi.getInstance(context).getTimelineEvents(from, to).forEach { event ->
print("Event ID: ${event.id}")
}import EventTimelineApi from '@sentiance-react-native/event-timeline';
const from = new Date(0); // 01/01/1970
const to = new Date(2 ** 31 * 1000);
const events = await EventTimelineApi.getTimelineEvents(from.getTime(), to.getTime());
for (const event of events) {
console.log(`Event ID: ${event.id}`);
}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.
Checkout Real-Time Listeners for more details
Synchronising Insights with Your Backend
A common practice 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.
Checkout Data Synchronization for more details
Last updated