Install with Swift Package Manager
In Xcode, select File → Add Package Dependencies and add:DatalyrSDK product to your app target.
Initialize
Track an event
Identify a user
Track a screen
- SwiftUI
- Swift
Core methods
| Method | Use it to |
|---|---|
DatalyrSDK.configure(...) | Initialize the shared SDK. |
datalyrTrack(...) | Track an event. |
datalyrScreen(...) | Track a screen view. |
datalyrIdentify(...) | Identify a user. |
datalyrAlias(...) | Link two IDs for the same user. |
datalyrReset() | Clear identity on logout. |
datalyrFlush() | Send queued events immediately. |
datalyrGetAnonymousId() | Read the persistent anonymous ID. |
datalyrTrackPurchase(...) | Track purchase revenue. |
datalyrTrackSubscription(...) | Track subscription revenue. |
datalyrReset() when a user signs out.
CocoaPods
pod install and open the generated workspace.
Configuration
| Option | Default | What it controls |
|---|---|---|
apiKey | Required | Workspace API key. |
debug | false | Development logging. |
maxRetries | 3 | Delivery retries. |
retryDelay | 1 | Delay between retries in seconds. |
timeout | 15 | Request timeout in seconds. |
batchSize | 10 | Events sent in each batch. |
flushInterval | 10 | Automatic flush interval in seconds. |
maxQueueSize | 1000 | Maximum queued events. |
enableAutoEvents | true | App lifecycle and session events. |
enableAttribution | true | Deep-link and campaign attribution. |
autoEventConfig | — | Fine-grained automatic event settings. |
skadTemplate | — | SKAdNetwork template for conversion values. |
Automatic events
.datalyrScreen() modifier.
Identity
datalyrAlias only to join two IDs for the same person. Call datalyrReset() on logout or account switching.
Revenue and subscriptions
Attribution and deep links
Pass incoming links to the SDK:App Tracking Transparency
RevenueCat and Superwall
Diagnostics
getStatus() during setup verification and datalyrFlush() before a controlled shutdown or background transition when immediate delivery matters.