📄️ Overview
This guide walks you through adding the B2Metric iOS SDK to your app, from the first pod install to the last line of a shutdown call. It's written for the engineer who's about to do the integration, not for a general audience, so it stays close to code and skips the marketing talk.
📄️ Installation
Swift Package Manager
📄️ Upgrading from 1.x
Version 2.0.0 aligns the iOS SDK's payload and behaviour with the other B2Metric platform SDKs (Android, Flutter, React Native). Two changes require an edit at your call sites:
📄️ Quick Start
Start the SDK once, as early as possible — e.g. in your App init or AppDelegate:
📄️ Configuration
| Parameter | Type | Default | Range | Description |
📄️ Event Tracking
Log an Event
📄️ User Identification
Call setUser to associate events with a known user.
📄️ Push Notifications
Register Device Token
📄️ Screen Tracking
UIViewController appearances are tracked automatically as screen_view events. For SwiftUI, mark the views you want tracked:
📄️ Sessions
A session starts on first launch and ends after sessionTimeoutMinutes of inactivity. The SDK emits sessionstart when a session begins and sessionend (carrying duration_seconds) once the previous session is found to have expired. Sessions survive app restarts within the timeout window.
📄️ Offline Behaviour
Events are persisted on device and delivered in batches. While offline the SDK skips delivery and keeps events queued, then flushes automatically when connectivity returns. If the queue reaches maxQueueSize, the oldest events are dropped first.
📄️ Lifecycle Management
Flush on Demand
📄️ Best Practices
Privacy & Sensitive Data
📄️ Troubleshooting
| Symptom | Resolution |
📄️ API Reference
B2MAnalytics
📄️ Support
Resources
📄️ Release History
v2.0.0