SpikeSDK Flutter (v3)
iOS 13.0+ Android 9.0+ (Level 28, P, Pie)
Add ependency on SpikeSDK in your pubspec.yaml file:
Use pod install and pod update commands from ios/ folder of your app to install/update SpikeSDK.
To add HealthKit support to your application's Capabilities.
- Open the ios/ folder of your project in Xcode
- Select the project name in the left sidebar
- Open Signing & Capabilities section
- In the main view select '+ Capability' and double click HealthKit
More details you can find here.
Add Health Kit permissions descriptions to your Info.plist file:
To add the SDK to your Android project, you have to add the following to your project's build.gradle file in the repositories block.
Set Android SDK version in local.properties file:
Include the necessary health permissions in your AndroidManifest.xml to fully leverage the Spike SDK and access data from apps integrated with Health Connect. Please refer to this guide for details on the required permissions.
Note: Only request permissions essential to your app’s functionality. Requesting unused permissions will lead to app store rejection!
Add an intent filter to your activity definition so that you can request the permissions at runtime.
Check the contents of android/app/src/main/kotlin/{YOUR_PACKAGE_ID}/MainActivity.kt. You must see something like that in case it is the new app being developed:
You must change FlutterActivity to the FlutterFragmentActivity which means that your code should turn into the result similar to the one below:
In the Health Connect permissions activity, there is a link to your privacy policy. You need to grant the Health Connect app access in order to link back to your privacy policy. In the example below, you should either replace .MainActivity with an activity that presents the privacy policy or have the Main Activity route the user to the policy. This step may be required to pass Google app review when requesting access to sensitive permissions.
Note: If permissions handling is not working, this might be related to launch mode being singleTop. This might be not needed, but some apps face problems when requesting permissions. If you face them, then you should try removing the following line:
Note: If app is not building, it might be related to label replacement issue. In this case, you should add the following line:
If you plan to use Android Health Connect and/or Apple HealthKit data providers you should first get users permission to use their data:
-
Info: The maximum permitted date range is 90 days There are two types of data you can retrieve from Spike:
- Records consist of the raw data points collected from user devices or applications.
- Statistics, on the other hand, are calculated values derived from records.
Now you can read hourly statistics data of steps and distance for today:
where:
where: