SpikeSDK React Native (v3)
iOS 13.0+ Android 9.0+ (Level 28, P, Pie)
Install the react-native-spike-sdk package from npm:
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.
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 may lead to app store rejections.
Add an intent filter to your activity definition so that you can request the permissions at runtime.
To handle Android 14 you also need to add activity-alias to your AndroidManifest.xml It is just a wrapper for the activity that requests permissions so no real activity is necessary.
To set up the Spike SDK create SpikeConnectionV3 instance with your Spike application id, auth token and user id unique to each of your users:
If you plan to use Android Health Connect and/or Apple HealthKit data providers you should first get users permission to use their data:
- for Android there are more methods that let you get permissions granted by user, check if Health Connect is installed or should be updated, etc. If you are OK with SpikeSDK handling these, you can use requestHealthPermissions only. On iOS requestHealthPermissions is the only method that has to be called. Keep in mind, that you should do it before trying to read data from Android Health Connect or Apple HealthKit.
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: