Mobile SDKs

SpikeSDK Flutter (v3)

Current Flutter SDK Version: 4.0.14

Flutter Package can be found here

Example app can be found here

Requirements

iOS 13.0+ Android 9.0+ (Level 28, P, Pie)

Installation

Add ependency on SpikeSDK in your pubspec.yaml file:

YAML


iOS Setup Guide

Use pod install and pod update commands from ios/ folder of your app to install/update SpikeSDK.

iOS Signing & Capabilities

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.

Info.plist

Add Health Kit permissions descriptions to your Info.plist file:

Text


Android Setup Guide

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.

Text


Set Android SDK version in local.properties file:

Text


Android permissions

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!

XML


Add an intent filter to your activity definition so that you can request the permissions at runtime.

XML


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:

Kotlin


You must change FlutterActivity to the FlutterFragmentActivity which means that your code should turn into the result similar to the one below:

Kotlin


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.

XML


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:

XML


Note: If app is not building, it might be related to label replacement issue. In this case, you should add the following line:

XML

XML


Spike SDK Usage

Step 1 - Create Spike connection

Dart


Step 2 - ask user for permissions

If you plan to use Android Health Connect and/or Apple HealthKit data providers you should first get users permission to use their data:

Dart

  • 

Step 3 - Get 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.

Statistics

Now you can read hourly statistics data of steps and distance for today:

Dart


where:

Dart


Records

Dart


where:

Dart