For the complete documentation index, see llms.txt. This page is also available as Markdown.

Declaring 3rd Party Plugins

Chances are, your app has other dependencies than just the Sentiance SDKs.

In case you needed to use a certain dependency/plugin inside your listener registration callbacks, you need to let the Sentiance SDK know so that its usage possible. Without it, you will not be able to utilize other plugins inside the Dart callback.

Consider the example below:

background.dart
import 'package:sentiance_core/sentiance_core.dart';
import 'package:sentiance_event_timeline/sentiance_event_timeline.dart';
import 'package:sqflite/sqflite.dart' as sqflite;

@pragma('vm:entry-point')
Future<void> registerEventTimelineListener() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SentianceCore.ensureInitialized(); // Make sure the SDK is initialized

  final sqliteDatabase = sqflite.openDatabase(...);
  final corePlugin = SentianceCore();
  final eventTimelinePlugin = SentianceEventTimeline();

  SentianceEventTimeline.registerEventTimelineUpdateListener((timelineEvent) async {
    final userId = await corePlugin.getUserId();
    eventTimelinePlugin.setTransportTags({"tag": "value"});
  });
}

The call on line 10 will fail unless you register the sqflite plugin. However, the calls on line 11 and 12 will work out of the box without you having to register the core and event timeline plugins since the Sentiance SDK takes care of registering them for you on the Flutter engine that is currently running this Dart function.

To register the sqflite plugin, follow the recommended approach as follows by registering the plugin individually:

You can also choose to register all the plugins of your app instead, if that would be more practical. Please note that this will result in the SDK logging a warning that the Sentiance plugins you registered (via GeneratedPluginRegistrant) are already auto-registered on every Sentiance background engine, so registering them yourself is no longer needed.

That's it. Your listener is now set up to get updates from the Sentiance SDK in the background, and can work side-by-side with other plugins that your app requires.

Last updated