Skip to main content
Version: 3.0.0

Impilo Mobile SDK Integration Guide

This guide covers the basic steps to integrate the Impilo Mobile SDK into your Flutter application.

1. Unzip and Add the SDK​

  1. Extract the SDK zip file to your project directory:

    unzip impilo_mobile_sdk_flutter.zip
  2. Add the SDK to your pubspec.yaml:

    dependencies:
    flutter:
    sdk: flutter
    impilo_mobile_sdk:
    path: ./impilo_mobile_sdk
  3. Run flutter pub get to install the dependency.

2. iOS Configuration​

Apple Health Permissions​

Add the following entries to your ios/Runner/Info.plist:

<key>NSHealthShareUsageDescription</key>
<string>This app requires access to read your health data to provide health monitoring features.</string>
<key>NSHealthUpdateUsageDescription</key>
<string>This app requires access to save health data to your Health app.</string>

Bluetooth Permissions​

If you're using Bluetooth devices, also add:

<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app requires Bluetooth access to connect to medical devices such as blood pressure monitors.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>This app requires Bluetooth access to connect to medical devices such as blood pressure monitors.</string>

HealthKit Entitlements​

  1. Create ios/Runner/Runner.entitlements with the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>com.apple.developer.healthkit</key>
    <true/>
    <key>com.apple.developer.healthkit.access</key>
    <array/>
    </dict>
    </plist>
  2. In Xcode, add the entitlements file to your project:

    • Open ios/Runner.xcodeproj in Xcode
    • Select the Runner target
    • Go to "Signing & Capabilities"
    • Click "+ Capability" and add "HealthKit"
    • Or manually add to build settings: CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements

Podfile Configuration​

Add the ImpiloMobileSDK pod reference at the end of your ios/Podfile:

pod 'ImpiloMobileSDK', :path => '../impilo_mobile_sdk/ios/ImpiloMobileSDK'

Then run:

cd ios && pod install

3. Basic SDK Usage​

Request Runtime Permissions (Android)​

On Android, you need to request Bluetooth permissions at runtime before initializing the SDK. Add the permission_handler package to your pubspec.yaml:

dependencies:
permission_handler: ^11.3.1

Then request permissions before SDK initialization:

import 'package:permission_handler/permission_handler.dart';
import 'dart:io';

// Request Bluetooth permissions on Android
if (Platform.isAndroid) {
final bluetoothConnect = await Permission.bluetoothConnect.request();
final bluetoothScan = await Permission.bluetoothScan.request();

if (!bluetoothConnect.isGranted || !bluetoothScan.isGranted) {
// Handle permission denial
return;
}
}

Initialize the SDK​

import 'package:impilo_mobile_sdk/impilo_mobile_sdk.dart';
import 'dart:io';

// Initialize the SDK (after requesting Bluetooth permissions on Android)
final sdk = await ImpiloSDK.initialize(
loggerConfig: LoggerConfiguration(
enabled: true,
minimumLevel: LogLevel.debug,
),
);

// Request Health Connect/Apple Health access
if (Platform.isAndroid) {
// Request Health Connect access
await sdk.androidHealthConnect.requestAccess(
readTypes: [AndroidHealthConnectReadingType.bloodPressure],
writeTypes: [AndroidHealthConnectReadingType.bloodPressure],
);
} else if (Platform.isIOS) {
// Request Apple Health access
await sdk.appleHealth.requestAccess(
readTypes: [AppleHealthReadingType.bloodPressure],
writeTypes: [AppleHealthReadingType.bloodPressure],
);
}

Discover and Pair Bluetooth Device​

// Discover Transtek blood pressure monitors
final discoveredDevices = <Unpaired<TranstekBBZ32BB01>>[];

TranstekBBZ32BB01.discover(sdk)((unpairedDevice) {
print('Found device: ${unpairedDevice.bluetoothIdentifier()}');
discoveredDevices.add(unpairedDevice);
});

// Pair with a discovered device
unpairedDevice.pair((pairedDevice) {
print('Device paired successfully!');
// Store pairedDevice for monitoring
});

Monitor for Blood Pressure Readings​

// Start monitoring for readings from paired device
pairedDevice.monitorForReading((bpReading) async {
print('BP: ${bpReading.data.systolicInMmHg}/${bpReading.data.diastolicInMmHg} mmHg');

// Save to Apple Health
await sdk.appleHealth.bloodPressure.insert(bpReading);
print('Saved to Apple Health');
});

4. Android Configuration​

Minimum SDK Version​

The SDK requires Android API 26+ (Android 8.0) for Health Connect support. Update your android/app/build.gradle.kts:

android {
defaultConfig {
minSdk = 26 // Health Connect requires API 26+
}
}

Android Permissions​

Add the following permissions to your android/app/src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Bluetooth permissions for device connectivity -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<!-- Health Connect permissions (API 28+) -->
<uses-permission android:minSdkVersion="28" android:name="android.permission.health.READ_BLOOD_PRESSURE" />
<uses-permission android:minSdkVersion="28" android:name="android.permission.health.WRITE_BLOOD_PRESSURE" />

<application>
<activity
android:name=".MainActivity"
android:exported="true">
<!-- Your existing intent filters -->

<!-- Intent filter for Health Connect -->
<intent-filter>
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
</intent-filter>
</activity>

<!-- Activity alias for Health Connect integration -->
<activity-alias
android:name="ViewPermissionUsageActivity"
android:exported="true"
android:targetActivity=".MainActivity"
android:permission="android.permission.START_VIEW_PERMISSION_USAGE">
<intent-filter>
<action android:name="android.intent.action.VIEW_PERMISSION_USAGE" />
<category android:name="android.intent.category.HEALTH_PERMISSIONS" />
</intent-filter>
</activity-alias>
</application>

<queries>
<!-- Query for Health Connect package -->
<package android:name="com.google.android.apps.healthdata" />
</queries>
</manifest>

Gradle Settings​

Add the native SDK modules to your android/settings.gradle.kts:

include(":app")

// Include native SDK modules from the impilo_mobile_sdk plugin
val nativeSdkDir = File(settingsDir, "../impilo_mobile_sdk/android/native-sdk")
if (nativeSdkDir.exists()) {
include(":native-sdk:orchestration")
include(":native-sdk:impilomobilesdk")
project(":native-sdk:orchestration").projectDir = File(nativeSdkDir, "orchestration")
project(":native-sdk:impilomobilesdk").projectDir = File(nativeSdkDir, "impilomobilesdk")
}

Health Connect Usage​

For Android, use Health Connect instead of Apple Health:

// Request Health Connect access
await sdk.androidHealthConnect.requestAccess(
readTypes: [AndroidHealthConnectReadingType.bloodPressure],
writeTypes: [AndroidHealthConnectReadingType.bloodPressure],
);

// Save to Health Connect
await sdk.androidHealthConnect.bloodPressure.insert(bpReading);