Swift
Spike Swift SDK is a library on top of HealthKit that
- helps with the extraction of data.
- pushes data to SpikeAPI and delivers standardized data.
- iOS 13.0+
- Xcode 13.0+
- Swift 5+
Go to your target's Signing & Capabilities section and add HealthKit.
Allow Clinical Health Records, Background fetch, and Background Delivery.

More details you can find here.
Add Health Kit permissions descriptions to your Info.plist file.
CocoaPods is a dependency manager for Cocoa projects. To integrate SpikeSDK into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'SpikeSDK', '0.2.10'
Use pod install and pod update commands to install/update pods afterward.
1. Import SpikeSDK to your project.
import SpikeSDK
2. Add Spike initialization code to application(_:didFinishLaunchingWithOptions:) in your AppDelegate file.
Spike.shared.initialize()
3. Provide SpikeDelegate to handle results from SpikeSDK.
Spike.shared.delegate = self
4. Setup with client id, authorization token, user id, and optionally postback URL.
Spike.shared.setup(clientId: {CLIENT_ID}, authToken: {AUTH_TOKEN}, userId: {USER_ID}, postbackURL: {URL/nil})
- If you leave postbackURL empty then SDK sends standardized data back to your app in the same request.
- If you provide postbackURL then SDK sends standardized data back to your servers.
- You need postbackURL if you will use Spike.shared.enableBackgroundDelivery.
Get data for specified Spike Data types. All available Data types: step, heartRate, restingHeartRate, activeEnergy, basalEnergy, appleMoveTime, appleExerciseTime, distanceWalkingRunning, floors, workouts, sleepAnalysis.
Spike.shared.getData(for: SpikeDataTypes.allCases)
Spike.shared.getData(for: [.step, .heartRate, .appleExerciseTime])
Data will be sent to your webhook if postbackURL is configured.
Spike.shared.enableBackgroundDelivery(for: SpikeDataTypes.allCases)
Spike.shared.disableAllBackgroundDelivery()
Spike.shared.isBackgroundUpdateEnabled
With enabled debug mode SpikeSDK will print performed actions. It is better to call this before calling Spike.shared.initialize().
By overriding spikeLog methods of SpikeDelegate you can handle public debug logs from your side.
spikeInitialized(with uuid: String)
spikeInitializationFailure()
spikeDataResult(_ result:SpikeResult<SpikeResultData>)
spikeWorkoutDataResult(_ result: SpikeResult <SpikeWorkoutResultData> )
spikeSleepAnalysisDataResult(_ result: SpikeResult<SpikeSleepAnalysisResultData>)
SpikeResult contains the status and array of data.
If you have provided postbackURL to the setup method, the status will be returned, otherwise data.
spikeDataFailure()
spikeWorkoutDataFailure()
spikeSleepAnalysisFailure()
spikeLog(_ log: String)
Spike.shared.getCurrentUUID()
Spike.shared.clearData()