> For the complete documentation index, see [llms.txt](https://docs.sentiance.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sentiance.com/sdk/appendix/flutter/declaring-3rd-party-plugins.md).

# 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:

{% code title="background.dart" lineNumbers="true" %}

```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"});
  });
}
```

{% endcode %}

The call on line **10** will fail unless you register the [**sqflite**](https://pub.dev/packages/sqflite) plugin. However, the calls on line **11** and **12** will work out of the box without you having to register the [**core**](https://pub.dev/packages/sentiance_core) and [**event timeline**](https://pub.dev/packages/sentiance_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.&#x20;

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

{% tabs %}
{% tab title="iOS" %}
{% code title="AppDelegate.swift" %}

```swift
import Flutter
import UIKit
import sentiance_core
import sentiance_event_timeline
import sqflite_darwin

@main
@objc class AppDelegate: FlutterAppDelegate {

    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        // other code

        // Initialize the Sentiance SDK first
        SentianceCorePlugin.shared.initializeAsync(launchOptions: launchOptions) { result, error in
            if result != nil {
                // Replace '<your_app_package_name>' with the name of your app package
                // as shown inside your project's pubspec.yaml file
                let libraryURI = "package:<your_app_package_name>/background.dart"
                let dartCallbackName = "registerEventTimelineListener"

                SentianceEventTimelinePlugin.initializeListener(
                    withEntryPoint: dartCallbackName,
                    libraryURI: libraryURI,
                    includeProvisionalEvents: true
                ) { flutterEngine in
                    // flutterEngine is the environment where your Dart callback runs
                    SqflitePlugin.register(with: flutterEngine.registrar(forPlugin: "sqflite")!)
                }
            } else {
                print("Sentiance SDK initialization failed, reason: \(String(describing: error?.failureReason))")
            }
        }

        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
}

```

{% endcode %}
{% endtab %}

{% tab title="Android" %}
{% code title="MainApplication.kt" %}

```kotlin
import android.app.Application
import com.sentiance.core_plugin.CorePlugin
import com.sentiance.event_timeline_plugin.EventTimelinePlugin
import com.tekartik.sqflite.SqflitePlugin

class MainApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        // Initialize the Sentiance SDK first
        CorePlugin.initializeAsync(this)
            .addOnSuccessListener {
                val dartLibrary = "package:<your_app_package_name>/background.dart"
                val dartCallbackName = "registerEventTimelineListener"

                EventTimelinePlugin.initializeListener(
                    context = this,
                    dartEntryPointLibrary = dartLibrary,
                    dartEntryPointFunctionName = dartCallbackName,
                    includeProvisionalEvents = true
                ) { flutterEngine ->
                    // flutterEngine is the environment where your Dart callback runs
                    flutterEngine.plugins.apply {
                        add(SqflitePlugin())
                        // add here any other non-Sentiance plugin that you intend to use
                    }
                }
            }

        // Other code
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

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.&#x20;

{% tabs %}
{% tab title="iOS" %}
{% code title="AppDelegate.swift" %}

```swift
import Flutter
import UIKit
import sentiance_core
import sentiance_event_timeline

@main
@objc class AppDelegate: FlutterAppDelegate {

    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        // other code

        // Initialize the Sentiance SDK first
        SentianceCorePlugin.shared.initializeAsync(launchOptions: launchOptions) { result, error in
            if result != nil {
                // Replace '<your_app_package_name>' with the name of your app package
                // as shown inside your project's pubspec.yaml file
                let libraryURI = "package:<your_app_package_name>/background.dart"
                let dartCallbackName = "registerEventTimelineListener"

                SentianceEventTimelinePlugin.initializeListener(
                    withEntryPoint: dartCallbackName,
                    libraryURI: libraryURI,
                    includeProvisionalEvents: true
                ) { flutterEngine in
                    // flutterEngine is the environment where your Dart callback runs

                    // GeneratedPluginRegistrant is generated by the Flutter tool
                    // available under the GeneratedPluginRegistrant.h header file, and
                    // allows you to register all of your app's plugins with a single flutter engine
                    GeneratedPluginRegistrant.register(with: flutterEngine)
                }
            } else {
                print("Sentiance SDK initialization failed, reason: \(String(describing: error?.failureReason))")
            }
        }

        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
}
```

{% endcode %}
{% endtab %}

{% tab title="Android" %}
{% code title="MainApplication.kt" %}

```kotlin
import android.app.Application
import com.sentiance.core_plugin.CorePlugin
import com.sentiance.event_timeline_plugin.EventTimelinePlugin
import io.flutter.plugins.GeneratedPluginRegistrant

class MainApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        // Initialize the Sentiance SDK first
        CorePlugin.initializeAsync(this)
            .addOnSuccessListener {
                val dartLibrary = "package:<your_app_package_name>/background.dart"
                val dartCallbackName = "registerEventTimelineListener"

                EventTimelinePlugin.initializeListener(
                    context = this,
                    dartEntryPointLibrary = dartLibrary,
                    dartEntryPointFunctionName = dartCallbackName,
                    includeProvisionalEvents = true
                ) { flutterEngine ->
                    // flutterEngine is the environment where your Dart callback runs

                    // The GeneratedPluginRegistrant class is generated by the Flutter tool
                    // and allows you to register all of your app's plugins with a single flutter engine
                    GeneratedPluginRegistrant.registerWith(flutterEngine)
                }
            }

        // Other code
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

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.
