Combain Indoor AI Navigation Plugin
This plugin is a wrapper for the Combain Indoor AI Navigation SDK. It provides a simple way to integrate the SDK into your Flutter app.
Installation
First update android/build.gradle.kt to include the Combain Maven repository:
repositories {
maven(url = "https://gitlab.com/api/v4/projects/3194773/packages/maven") <- ADD THIS
google()
mavenCentral()
}
Then include the SDK in your pubspec.yaml:
dependencies:
flutter_combainsdk: ^0.4.9
...
Permissions
After this you need to manage permissions
Android
For proper permission handling, your MainActivity must extend FlutterFragmentActivity instead of the default FlutterActivity. This is required because the SDK needs access to ComponentActivity features for permission management.
In your android/app/src/main/kotlin/.../MainActivity.kt:
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity: FlutterFragmentActivity()
Note: If your MainActivity currently extends FlutterActivity, simply change it to FlutterFragmentActivity and update the import statement.
Required Permissions in AndroidManifest.xml
Add the following permissions to your android/app/src/main/AndroidManifest.xml file:
<!-- Required permissions for Bluetooth and location services -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
Note: These permissions are required for the SDK to function properly, especially for Bluetooth beacon detection and location services. The neverForLocation flag on BLUETOOTH_SCAN indicates that Bluetooth scanning is not used for location purposes.
Note: You might want to ask for notifications more gracefully. When you run ´start()´ the SDK will ask for all required permissions. If you wish to use onboarding for this see example project: at lib/screens/setup/permissions_setup.dart
Permissions
iOS
The following values needs to be specified in the info.plist
NSMotionUsageDescriptionNSLocationWhenInUseUsageDescription
And this needs to be added to Podfile:
target.build_configurations.each do |config|
# You can remove unused permissions here
# for more information: https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
# e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## The 'PERMISSION_LOCATION' macro enables the `locationWhenInUse` and `locationAlways` permission. If
## the application only requires `locationWhenInUse`, only specify the `PERMISSION_LOCATION_WHENINUSE`
## macro.
##
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
'PERMISSION_LOCATION_WHENINUSE=1',
'PERMISSION_SENSORS=1',
]
end
See https://github.com/Baseflow/flutter-permission-handler/tree/main/permission_handler#setup
Getting Started
Now you are ready to start recieving indoor location updates This is all the code needed to start receiving indoor location updates from the Combain Indoor AI Navigation SDK.
CombainSDKConfig indoorNavigationConfig = CombainSDKConfig(
apiKey: env.combainApiKey,
settingsKey: env.combainApiKey, // Leave as empty string to only use apiKey
locationProvider: FlutterLocationProvider.aiNavigation,
routingConfig: FlutterRoutingConfig(
routableNodesOptions: FlutterRoutableNodesOptions.allExceptDefaultName,
),
appInfo: FlutterAppInfo(
packageName: _packageInfo.packageName, // See https://pub.flutter-io.cn/packages/package_info_plus
versionName: _packageInfo.version,
versionCode: int.tryParse(_packageInfo.buildNumber) ?? 0,
),
syncingInterval: FlutterSyncingInterval(
type: FlutterSyncingIntervalType.interval,
intervalMilliseconds: 60 * 1000 * 60,
),
wifiEnabled: true,
bluetoothEnabled: true,
beaconUUIDs: ["E2C56DB5-DFFB-48D2-B060-D0F5A71096E0"], // For iOS iBeacon to work, leave as empty array if not used on iOS
)
CombainSDKConfig slamConfig = CombainSDKConfig(
apiKey: env.combainApiKey,
settingsKey: env.combainApiKey, // Leave as empty string to only use apiKey
locationProvider: FlutterLocationProvider.slam,
appInfo: FlutterAppInfo(
packageName: _packageInfo.packageName, // See https://pub.flutter-io.cn/packages/package_info_plus
versionName: _packageInfo.version,
versionCode: int.tryParse(_packageInfo.buildNumber) ?? 0,
),
syncingInterval: FlutterSyncingInterval(
type: FlutterSyncingIntervalType.interval,
intervalMilliseconds: 60 * 1000 * 60,
),
wifiEnabled: true,
bluetoothEnabled: true,
beaconUUIDs: ["E2C56DB5-DFFB-48D2-B060-D0F5A71096E0"], // For iOS iBeacon to work, leave as empty array if not used on iOS
);
Future<void> initSDK() async {
// Step 1: Create the SDK instance with logging and exception capture
final combainSDK = await FlutterCombainSDK.create();
await _combainSDK.initializeSDK(indoorNavigationConfig); // Use slamConfig for SLAM
await combainSDK.start();
}
Demo
For a demo project see gitlab.combain.com/Hugo-Persson/flutter-ai-navigation-demo or github.com/careerfairsystems/arkad-app-flutter