React Native
Spike React Native SDK is a library on top of HealthKit that 1) helps with the extraction of data. 2) pushes data to SpikeAPI and delivers standardized data.
Installation
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 pods afterward.
Compatibility and requirements
iOS 13.0+
Add 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
- Allow Clinical Health Records and Background Delivery if needed.
Update Info.plist
Add Health Kit permissions descriptions to your ios/<Project Name>/Info.plist file.
Configure and Start
Import SpikeSDK
Add Spike initialization code to App.tsx file outside the App component.
Setup SpikeSDK Events
Use useSpikeEvents hook to handle results from SpikeSDK.
Setup SpikeSDK
Provide SpikeSDK with client id, authorization token, user id and optionally postback (webhook) URL.
Check for current session Promise<string | undefined>:
Remove session data:
Get Data
Get data for specified Spike Data types.
or
All available Data types SpikeDataType or use all of the instantly SpikeDataTypesAll: DataTypeStep DataTypeHeartRate DataTypeRestingHeartRate DataTypeActiveEnergy DataTypeBasalEnergy DataTypeAppleMoveTime DataTypeAppleExerciseTime DataTypeDistanceWalkingRunning DataTypeFloors DataTypeWorkout DataTypeSleepAnalysis
Getting DataTypeWorkout data will return results through the onWorkoutDataResult and onWorkoutDataFailure callbacks of useSpikeEvents hook.
Getting DataTypeSleepAnalysis data will return results through the onSleepAnalysisDataResult and onSleepAnalysisDataFailure callbacks of useSpikeEvents hook.
Enable debug mode
With enabled debug mode SpikeSDK will print performed actions. You can see logs directly running the application from Xcode. Use logs filter [SpikeSDK]. It is better to call this before calling Spike.initialize();.
Background data updates
Allow update data for specified Spike Data types and send it to Spike.
Add Capabilities
Go to your target's Signing & Capabilities section and add Background Modes. Allow Background fetch. And check Info.plist for UIBackgroundModes.
Enabling data background updates
Disabling data background updates
Checking background updates