Configuration
SDK Initialization
BioSDK is initialized asynchronously. The initialize call fetches device profiles from the AnyBio platform and prepares the BLE subsystem.
import BioSDK
let config = BioSDKClient.Configuration(
environment: .auto,
organizationKey: "org_your_key",
projectKey: "proj_your_key"
)
let sdk = try await BioSDKClient.initialize(configuration: config)
Store a strong reference to the BioSDKClient instance for the lifetime of your app. If it's deallocated, BLE connections and active sessions will be torn down.
Configuration Options
environment
Controls which AnyBio API endpoint the SDK connects to.
| Value | Behavior |
|---|---|
.auto | Reads BIO_INGEST_BASE_URL from your app's Environment.plist. |
.production | Uses the AnyBio production endpoint. |
organizationKey
Your organization identifier (prefixed with org_). Provided when you register with AnyBio.
projectKey
Your project identifier (prefixed with proj_). Each project groups sessions, devices, and data under a single namespace.
Environment.plist
Create an Environment.plist file in your app bundle to configure environment-specific settings:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BIO_INGEST_BASE_URL</key>
<string>https://api.anybio.io</string>
<key>DEVELOPER_KEY</key>
<string>org_your_key</string>
<key>PROJECT_KEY</key>
<string>proj_your_key</string>
<key>ENVIRONMENT</key>
<string>production</string>
</dict>
</plist>
Multiple Environments
Create separate plist files for each environment and switch them via Xcode build configurations or schemes:
| File | Base URL | Use case |
|---|---|---|
Environment.plist | https://api.anybio.io | Production |
Environment-beta.plist | https://apibeta.anybio.io | Beta / staging |
OAuth Configuration (Optional)
If your app uses AnyBio's OAuth provider integration:
sdk.configureOAuth(
callbackURLScheme: "yourapp",
userTokenProvider: {
// Return the current user's access token from your keychain
KeychainHelper.load(key: "accessToken")
}
)
Register your callback URL scheme in Info.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>yourapp</string>
</array>
<key>CFBundleURLName</key>
<string>com.yourcompany.yourapp.oauth</string>
</dict>
</array>
Client Info
The SDK automatically collects non-sensitive client metadata and sends it with session requests for diagnostics:
- App name, version, and build number
- OS name and version
- Device model
- SDK version
Access this information at any time:
let info = sdk.clientInfo
// ["sdk_version": "2.0.0", "os_version": "17.2", "device_model": "iPhone 15 Pro", ...]