Skip to content

SDK Integration

Once you receive the BiosenseSignal_Flutter_SDK_<VERSION>.zip file, you are ready to add the Flutter SDK to your application.

Follow the steps below to integrate the SDK into your application.

1. Add the Framework to your Project

1.1. Extract the content of the BiosenseSignal_Flutter_SDK_<VERSION>.zip file into the root folder of your project.

1.2. Add the following to your pubspec.yaml, under the dependencies section:

biosensesignal_flutter_sdk:
    path: ./BiosenseSignal_Flutter_SDK_<VERSION>

1.3. Run the following commands:

flutter pub get
cd ios
pod install

2. Android Integration with the SDK

2.1. In android/app/build.gradle modify minSdkVersion to 27.

2.2. In android/app/src/main/AndroidManifest.xml add the following:

<uses-permission android:name="android.permission.CAMERA"/>

<uses-feature android:name="android.hardware.camera" android:required="true"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front" android:required="true"/>
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>

2.3. In android/app/src/main/java/<YOUR_PATH>/MainActivity.java make sure MainActivity extends either FlutterActivity or FlutterFragmentActivity:

Kotlin
package com.biosensesignal.flutter_sample

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {

}
Java
package com.biosensesignal.flutter_sample;

import io.flutter.embedding.android.FlutterActivity;

public class MainActivity extends FlutterActivity {

}

Additional setup when using Polar devices:

2.4. In your app's repositories section, add JitPack:

repositories {
    ...
    maven { url 'https://jitpack.io' }
}

2.5. In your app's gradle dependencies section, add Polar dependencies:

dependencies {
    ...
    implementation 'com.github.polarofficial:polar-ble-sdk:5.1.0'
    implementation 'io.reactivex.rxjava3:rxjava:3.1.6'
    implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'
}

2.6. In your AndroidManifest.xml file, add the following permissions:

xml
<!-- The SDK needs Bluetooth scan permission to search for BLE devices. 
BiosenseSignal SDK doesn't use the scan to decide the location so "neverForLocation" permission 
flag can be used.-->
<uses-permission
    android:name="android.permission.BLUETOOTH_SCAN"
    android:usesPermissionFlags="neverForLocation"
    tools:targetApi="s" />

<!-- BiosenseSignal SDK needs Bluetooth connect permission to connect for found BLE devices.-->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<!-- Allows BiosenseSignal SDK to connect to paired bluetooth devices. Legacy Bluetooth permission,
which is needed on devices with API 30 (Android Q) or older. -->
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />

<!-- Allows BiosenseSignal SDK to discover and pair bluetooth devices. Legacy Bluetooth permission,
which is needed on devices with API 30 (Android Q) or older. -->
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />

<!-- BiosenseSignal SDK needs the fine location permission to get results for Bluetooth scan. Request
fine location permission on devices with API 30 (Android Q). Note, if your application 
needs location for other purposes than bluetooth then remove android:maxSdkVersion="30"-->
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="30" />

<!-- The coarse location permission is needed, if fine location permission is requested. Request
coarse location permission on devices with API 30 (Android Q). Note, if your application 
needs location for other purposes than bluetooth then remove android:maxSdkVersion="30" -->
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="30" />

Build Android App Bundle (.aab)

When building the app as Android App Bundle (.aab extension), add the useLegacyPackaging flag to build.gradle file in the android folder, under the android section as the following example:

android {   
    packagingOptions {
        jniLibs {
            useLegacyPackaging = true
        }
    }
}

3. iOS Integration with the SDK

3.1. Grant the application camera permission in info.plist :

<key>NSCameraUsageDescription</key>
<string>Used for vital signs monitoring</string>

Additional setup when using Polar devices:

3.2. Grant the application bluetooth permission in info.plist

xml
<key>NSBluetoothAlwaysUsageDescription</key>
<string>App needs access to your bluetooth in order to measure your health.</string>

3.3. Grant the application background mode permission in info.plist

xml
<key>UIBackgroundModes</key>
<array>
    <string>bluetooth-central</string>
</array>

iOS Simulator Compatibility

The SDK is compatible with the Xcode simulator and will compile and run smoothly.

However, please note that as the simulator does not support camera access, attempting to create a face session will result in an error with the code cameraCodeNoCameraError = 1001.