CARP Health Sampling Package
This library contains a sampling package for sampling health data from Apple Health and/or Google Fit to work with the
This packages supports sampling of the following
HealthDataType can be:
HealthDataType documentation for a complete list.
For Flutter plugins for other CARP products, see CARP Mobile Sensing in Flutter.
If you're interested in writing you own sampling packages for CARP, see the description on how to extend CARP on the wiki.
To use this package, add the following to you
pubspc.yaml file. Note that
this package only works together with
dependencies: flutter: sdk: flutter carp_core: ^latest carp_mobile_sensing: ^latest carp_health_package: ^latest ...
This package uses AndroidX. See Flutter AndroidX compatibility
Replace the content of the
android/gradle.properties file with the following lines:
org.gradle.jvmargs=-Xmx1536M android.enableJetifier=true android.useAndroidX=true
Add this permission in the
Info.plist file located in
<key>NSHealthShareUsageDescription</key> <string>We will sync your data with the Apple Health app to give you better insights</string> <key>NSHealthUpdateUsageDescription</key> <string>We will sync your data with the Apple Health app to give you better insights</string>
To use this package, import it into your app together with the
import 'package:carp_core/carp_core.dart'; import 'package:carp_mobile_sensing/carp_mobile_sensing.dart'; import 'package:carp_health_package/health.dart';
Before creating a study and running it, register this package in the SamplingPackageRegistry.
When defining a study protocol with this health measure, it would look like this:
// collect weight every day at 23:00 protocol.addTriggeredTask( RecurrentScheduledTrigger( type: RecurrentType.daily, time: TimeOfDay(hour: 23, minute: 00)), BackgroundTask() ..addMeasure(Measure(type: HealthSamplingPackage.HEALTH) ..overrideSamplingConfiguration = HealthSamplingConfiguration( healthDataTypes: [HealthDataType.WEIGHT])), phone);
example.dart file for a full example of how to set up a CAMS study protocol for this sampling package.