carp_mobile_sensing and configure a Flutter app on Android and iOS.
Install Package
Add CAMS dependencies to
pubspec.yaml and fetch packages.Configure Android
Configure permissions, services, and Gradle settings.
Configure iOS
Add Info.plist keys and AppDelegate notification setup.
Validate Setup
Build and verify permissions on physical devices.
1) Install the package
Add dependencies inpubspec.yaml:
2) Android configuration
1
Add required permissions
Include permissions for activity recognition, notifications, foreground execution, and battery behavior.
2
Configure plugin services/receivers
Add both
flutter_background and flutter_local_notifications declarations in <application>.3
Enable desugaring in Gradle
Add
isCoreLibraryDesugaringEnabled = true and the desugar dependency in android/app/build.gradle.kts.Android manifest permissions
Add permissions for:- activity recognition
- notifications (including scheduled notifications)
- foreground/background execution
- foreground service types used by
flutter_background
FOREGROUND_SERVICE_SPECIAL_USE must be aligned with the service subtype description shown to users.Android services/receivers
Inside<application>, declare both plugin services:
flutter_background
flutter_local_notifications
Android Gradle setup
Inandroid/app/build.gradle.kts, enable desugaring and add dependency (required by local notifications):
Android ic_launcher.png
Both the flutter_local_notification and the flutter_background plugins use the ic_launcher.png as the icon for notifications. Hence, this icon should be added as a drawable resource to the the Android head project in the android/app/src/main/res/drawable/ folder. You typically copy the /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png icon.
3) iOS configuration
1
Add Info.plist permissions
Add motion permission for step tracking and optional file-sharing keys.
2
Configure notifications in AppDelegate
Register
flutter_local_notifications callback and keep plugin registration.Info.plist keys
Add motion permission for step tracking:AppDelegate notification setup
Forflutter_local_notifications, add plugin registrant callback:
4) Final checks
1
Refresh and resolve dependencies
2
Build on each platform
3
Verify runtime permissions
Grant notification and motion/activity permissions on device and confirm background behavior.
Important: Explicit plugin dependencies may be neededAs discussed in Issue #530, some projects may need to explicitly add plugin dependencies that CAMS uses transitively.If you see build/runtime plugin registration issues, add the required plugins directly in your app
pubspec.yaml (for example flutter_local_notifications and flutter_background) and run: