Appearance
SDK Integration
Once you receive the Binah_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 Binah_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:
binah_flutter_sdk:
path: ./Binah_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/build.gradle
under the dependencies
section, add the library:
implementation (name: 'bnhsdk', ext: 'aar')
2.3. 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.4. In android/app/src/main/java/<YOUR_PATH>/MainActivity.java
make sure MainActivity
extends either FlutterActivity
or FlutterFragmentActivity
:
Kotlin
package ai.binah.flutter_sample
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
Java
package ai.binah.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.
Binah 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" />
<!-- Binah SDK needs Bluetooth connect permission to connect for found BLE devices.-->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- Allows Binah 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 Binah 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" />
<!-- Binah 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>
3.2. Open Xcode, and update project's target, under "Build Settings" as shown below:
- Make sure "-lstdc++" & "-ObjC" exists under "Other Linker Flags"
- Make sure to update "C++ Language Dialect" to "C++17"
Additional setup when using Polar devices:
3.3. 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.4. Grant the application background mode permission in info.plist
xml
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
</array>