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

Flutter

1

Add the Sentiance SDK package

Add the SDK package from pub.dev

Open a terminal and run the command below from yout flutter project root directory.

flutter pub get sentiance_core
2

Native platform setup

To include the Sentiance SDK as a dependency, you must complete the native platform setup for each target platform your application supports.

iOS
  1. Add the SDK to your Podfile

Open your Podfile and add the following line, Replace x.y.z with the specific SDK version you want to install

pod 'SENTSDK', '~> x.y.z'
  1. Navigate to your ios folder in Terminal and run pod install

  2. Configure Capabilities in Xcode

    1. Open iox/Runner.xcworkspace in Xcode

    2. Go to Signing & Capabilities tab of your Runner target

    3. Add the Background Modes capability if it is not already added.

    4. Enable the following background modes

      • Location updates

      • Background fetch

      • Background processing

  3. Update Permissions in Info.plist

    1. If it doesn’t already exist, add Permitted background task scheduler identifiers and include com.sentiance.backgroundtask.task_processing as a sub-item.

    2. Add the following keys with the appropriate usage descriptions

      • Location Always and When In Use Usage Description

      • Location Always Usage Description

      • Location When In Use Usage Description

      • Motion Usage Description

Android

Include the Sentiance repository

Add the Maven repository in android/build.gradle file, Add the lines below in the allprojects repositories make sure to use the correct syntax for your file.

  • Kotlin syntax maven { url = uri("https://repository.sentiance.com") }

  • groovy syntax maven { url "https://repository.sentiance.com"}

Add dependencies

Open the build.gradle file of your app module and add the following lines in the dependencies section (add this section if it does not exist yet), replace x.y.+ with the latest version from Versions & Changelog

Add Permissions to android Manifest

The SDK automatically includes some permissions, others are required to be specifically included in the Android Manifest. Include the permissions below in AndroidManifest.xml read more about permissions in ....

AndroidManifest.xml
    ...
    <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
</manifest>
3

SDK Initialization

The SDK must be initialized as early as possible in the native code and on the main thread. Follow the instructions below to initialize the SDK for your application’s target platform.

Follow below instructions to initialize the Sentiance SDK for ios. Make sure that initialization happens before the didFinishLaunchingWithOptions method returns

  1. Open ios/Runner/AppDelegate.swift

  2. Import the sentiance_core package

  3. Create a SDK instance and call the initialize method

  4. Perform some logic to verify the initialization

...
import sentiance_core

...
    GeneratedPluginRegistrant.register(with: self)
    let sentianceInit = SentianceCorePlugin.shared.initialize()
    if sentianceInit.isSuccessful {
        print("Sentiance SDK initialized")
    }
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

External Dependencies

In addition to the core Flutter SDK, the Sentiance Flutter SDKs have a dependency on the equatable package.

For external dependencies in the native SDKs, check out the following section for Android and this section for iOS.

Steps

1

Install the Sentiance Core Flutter package

Run the command in Terminal:

Terminal
flutter pub get sentiance_core

The module should now be added to your project's pubspec.yaml file.

pubspec.yaml
dependencies:
  flutter:
    sdk: flutter
  sentiance_core: ^6.23.0
  ...
2

Setup the Build Dependencies in the native folders

iOS Build Dependencies

  1. In the terminal, navigate to your project's iOS directory

  2. Run the command in Terminal:

Terminal
pod install --repo-update

Android Build Dependencies

Add the Sentiance repository to your project-level build.gradle file:

allprojects {
    repositories {
        ...
        maven { url "https://repository.sentiance.com" }
    }
}

This will allow Gradle to find and download the necessary native Sentiance SDK libraries.

3

Configuration and permissions

Next, we'll configure the project settings and permissions for both iOS and Android.

iOS Configuration and Permissions

Open your existing app project in Xcode.

For project and permission settings, follow these 3 steps from the Native iOS Setup guide:

Android Configuration

When the Sentiance SDK runs in the background, it starts a foreground service. This causes Android to display a notification in the notification shade, and an icon on the system bar.

To customize this notification, you can update the AndroidManifest.xml file as follows:

AndroidManifest.xml
<application ...>
    <meta-data android:name="com.sentiance.flutter.core.notification_id" android:value="1001"/>
    <meta-data android:name="com.sentiance.flutter.core.notification_title" android:resource="@string/app_name"/>
    <meta-data android:name="com.sentiance.flutter.core.notification_text" android:value="Touch to open."/>
    <meta-data android:name="com.sentiance.flutter.core.notification_icon" android:resource="@mipmap/ic_launcher"/>
    <meta-data android:name="com.sentiance.flutter.core.notification_channel_name" android:value="Detections"/>
    <meta-data android:name="com.sentiance.flutter.core.notification_channel_id" android:value="sentiance_detections"/>
    
    ...
</application>

By customizing the notification, you can tailor the appearance and behavior of the notification to match the branding and user experience of your application. This allows you to provide a seamless and consistent experience to your users while the Sentiance SDK operates in the background.

Please note that customizing the notification should be done carefully to ensure that it complies with Android guidelines and user preferences. By doing so, you can enhance the overall user experience and maintain a cohesive presentation of your app and the Sentiance SDK's background functionality.

4

Next: Initialize the SDK

After having included the Sentiance SDK, proceed to initializing the SDK.

Last updated