Best practices
We recommend following the bellow practices in your project:
Secret keys
It is recommended to use .xcconfig files and info.plist to store secrets:
Adding configuration file
Create a new configuration file and add your credentials.
Applying the secrets configuration file
In the Project navigator, click on your project to reach the project screen. Make sure you’re on the project’s Info tab.
Unfortunately, your Swift code can’t directly access any build settings. But, your code can read values from your app’s Info.plist, which is a file containing special metadata for your app.
Getting the value of the secret in code
To read values from your app's Info.plist use:
object(forInfoDictionaryKey key: String) -> Any?
Privacy & Permissions
Privacy
To enable your app to access the user’s HealthKit store, you must add the HealthKit capability to your app’s target and include a short description of the app’s functionality in its target’s Info.plist file.
Follow these steps to add the purpose string for reading health data to your app’s target:
In the Project navigator, select your target’s Info.plist file.
Move the mouse pointer over the “Information Property List” key.
Click the Add button (+) that appears.
Choose “Privacy - Health Share Usage Description”.
Double-click the Value column to the right of the key and enter your app’s purpose string.
Permissions
To request specific permissions, use the method requestPermissions(_ permissions: [HealthDataType]?, completion: @escaping (Result<Bool, Error>) -> Void)
his method accepts an array of HealthDataType objects to request the necessary permissions. To ensure RookSDK functions properly, we recommend including the following data types:stepCount
, height
, bodyMass
, heartRate
, heartRateVariabilitySDNN
, workout
, sleepAnalysis
, oxygenSaturation
.
App notifications
To increase engagement in an iOS app, it is recommended to use push notifications:
Personalize: Tailor notifications based on user preferences and behavior.
Timing: Send notifications at relevant moments when users are most likely to engage.
Be concise: Keep notifications short, clear, and compelling.