iOS
The DataSapien SDK is available for native iOS Swift apps.
Step 1: Register DataSapien project
Before you can add Mobile SDK to your app, you need to create your account and log into the Orchestrator using your registered domain.
Your authentication keys and host URLs will be provided after registration. You can obtain the required configuration keys by contacting the DataSapien team.
The iOS SDK is available as Swift Package Manager (SPM) packages that you can reference in an Xcode project. The DataSapien iOS Mobile SDK is developed using Swift.
Prerequisites
- Xcode 16.4 or higher
- Target iOS 16.0 or higher
- Set up a physical Apple device
Step 2: Add DataSapien iOS SDK to your app
SPM Installation
- In Xcode, go to File → Add Packages…
- Add the core SDK package:
- Enter SPM URL:
https://github.com/Data-Sapien/ds-ios-sdk-core - Select xcode-16-4 branch for Xcode 16.4+
- Enter SPM URL:
- (Optional) Add the health module if you need health data collection:
- Enter SPM URL:
https://github.com/Data-Sapien/ds-ios-sdk-health-module - Select xcode-16-4 branch for Xcode 16.4+
- Enter SPM URL:
- Build the project
Note: Only add the health module if you need health data collection features. If you use the health module, you'll need to configure HealthKit permissions and capabilities (see Step 2 below).
Step 3: Configure Info.plist
Required: OAuth Redirect
Add URL schemes and associated domains for OAuth flow:
Option 1: Custom URL Scheme (Recommended for development)
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>your-app-scheme</string>
</array>
</dict>
</array>
Option 2: Associated Domains (Recommended for production)
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:<YOUR_OAUTH_REDIRECT_HOST></string>
</array>
Note: For Associated Domains, you'll also need to enable the capability in Xcode (see Step 3 below) and configure an apple-app-site-association file on your server.
Add the following configurations to your Info.plist:
Optional: Installed Apps (for MeData collection)
If you want to collect installed apps data, add the following to your Info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>itms-apps</string>
<string>itms</string>
</array>
Optional: Health Permissions (only if using health-module)
If you're using the ds-ios-sdk-health-module, add HealthKit usage descriptions:
<key>NSHealthShareUsageDescription</key>
<string>This app needs access to your health data to provide personalized insights.</string>
Step 4: Enable Capabilities
Associated Domains (Required for OAuth)
If you're using ManagedAPIService with Associated Domains for OAuth redirects:
- In Xcode, select your project target
- Go to Signing & Capabilities tab
- Click + Capability
- Add Associated Domains capability
- Add your OAuth redirect domain:
applinks:<YOUR_OAUTH_REDIRECT_HOST>
Note: You'll need to configure an apple-app-site-association file on your server at https://<YOUR_OAUTH_REDIRECT_HOST>/.well-known/apple-app-site-association for universal links to work.
HealthKit Capability (only if using health-module)
- In Xcode, select your project target
- Go to Signing & Capabilities tab
- Click + Capability
- Add HealthKit capability
Note: HealthKit capability is only required if you're using the health module for health data collection.
Step 5: Initialize SDK in your app
Modify your Application Delegate's didFinishLaunchingWithOptions method:
import DataSapien
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let config = DataSapienConfig
.Builder()
.setAuth(
url: "<YOUR_AUTH_URL>",
clientId: "<YOUR_CLIENT_ID>",
clientSecret: "<YOUR_CLIENT_SECRET>",
scope: "<YOUR_AUTH_SCOPE>"
)
.setHost(
baseUrl: "<YOUR_HOST_URL>",
mediaUrl: "<YOUR_MEDIA_URL>"
)
.setdebug(true) // Optional debug logs
.build()
DataSapien.initialize(dataSapienConfig: config)
DataSapien.setup { result in
switch result {
case .success:
// SDK is ready to use
case .failure(let error):
// Handle setup error
}
}
return true
}
You can obtain the required configuration keys by contacting the DataSapien team. We recommend calling DataSapien.setup() at each app launch because the SDK fetches only optimized deltas.