Skip to main content

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.

add_configuration_file

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.

configuration_project

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.

infoplist

Getting the value of the secret in code

To read values from your app's Info.plist use:

object(forInfoDictionaryKey key: String) -> Any?

secrets_configuration

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:

  1. In the Project navigator, select your target’s Info.plist file.

  2. Move the mouse pointer over the “Information Property List” key.

  3. Click the Add button (+) that appears.

  4. Choose “Privacy - Health Share Usage Description”.

  5. Double-click the Value column to the right of the key and enter your app’s purpose string.

Privacy

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.