Setup iOS Project
Follow these steps to setup your iOS project for compatibility with the Sahha SDK.
Minimum Requirements
To use the Sahha SDK, your iOS project must support:
- iOS 14 or above
- Swift 5 or above
Step 1) Enable HealthKit
Before you can connect to Apple Health, you must enable the HealthKit capabilities for your app.
You add capabilities to your app using the Signing & Capabilities pane of the project editor.
Add `HealthKit` entitlement to your Xcode project
- Select your App Target in the Project panel
- Select
Signing & Capabilities - Tap the
+button - Select
HealthKitfrom the list - Double-click the capability to add it to your project
Step 1.1
In the Project navigator of the main window, select the project — the root group with the same name as your app — and in the project editor that appears, select the appropriate target and then click the Signing & Capabilities tab.
Step 1.2
In the toolbar, click the Library button (+) to open the Capabilities library. Alternatively, click + Capability to the left of the build configurations, or choose Editor > Add Capability. The Capabilities library displays only the capabilities available to the target platform and your program membership. Select a capability in the list to view its description on the right.
Step 1.3
Select HealthKit from the list of capabilities.
Step 1.4
After you add the HealthKit capability, Xcode links the HealthKit framework to your target and updates the target's entitlements file to include the HealthKit Entitlement. If Xcode automatically manages the signing of your app, it also enables HealthKit for your app's App ID.
Step 2) Background Delivery
In order for the Sahha SDK to passively collect health data, your app will need to enable background delivery for HealthKit.
Add `Background Delivery` capability to your Xcode project
To enable HealthKit run even while your app is in the background, perform the following:
-
Select your project in Xcode's Project navigator.
-
Select the app's target from the Targets list.
-
Click the Signing & Capabilities tab in the project editor.
-
Find the HealthKit capability.
-
Enable the nested Background Delivery capability.
Xcode adds the com.apple.developer.healthkit.background-delivery entitlement to the target's entitlements file.
Step 3) Add Usage Descriptions
HealthKit uses a fine-grained authorization mechanism to help protect the user's privacy; your app must request permission to read and, optionally, write each individual sample type it supports.
Before prompting the user for their permission, you must configure your app to include one or more purpose strings, which accurately and concisely describe why the app needs to read the user's health data, write health data to their HealthKit store, or both. The presence of these purpose strings is an App Store requirement for any app that integrates with HealthKit. The system displays this information to the user when requesting their permission, along with the specific sample types that your app needs to access, which helps them make an informed decision.
You will need to write a message explaining to the user why they should approve these permissions.
Add usage descriptions to your Xcode project
Follow these steps to add the usage description for reading health data to your app's target:
- Select your App Target in the Project panel
- Select
Info - Tap the
+button to add a new key - Choose
Privacy - Health Share Usage Description. - Write a clear description for the key value such as
This app needs your health info to deliver health scores. - Choose
Privacy - Motion Usage Description. - Write a clear description for the key value such as
This app needs access to motion to capture health information and trigger background processing.
Next Steps
Continue to Step 2.) Install SDK to install the Sahha SDK for iOS.
- Previous
- Step 1.) Setup Project
- Next
- Android