Troubleshooting
SDK Not Initializing
Problem: SDK throws errors or events aren't being sent.
Solution:
- Verify API key is not empty
- Enable debug logging:
B2MetricAnalytics.shared.logLevel = .debug
B2MetricAnalytics.shared.start(apiKey: "YOUR_API_KEY")
- Check Xcode console output for errors
Events Not Appearing
Problem: You're tracking events but don't see them in the dashboard.
Common causes:
- Events still in queue — For testing, send events immediately:
B2MetricAnalytics.shared.start(
apiKey: "YOUR_API_KEY",
batchSize: 1, // Send immediately
flushInterval: 5
)
-
No internet connection — Events are stored locally when offline and sent when connection is restored.
-
Wrong API key — Verify you're using the correct API key from the B2Metric dashboard.
Push Notification Tracking Not Working
APNs checklist:
- Push notifications capability enabled in Xcode
- APNs certificate configured in Apple Developer Portal
-
didRegisterForRemoteNotificationsWithDeviceTokenimplemented -
registerDeviceToken()called with device token -
didReceiveRemoteNotificationimplemented -
trackPushOpened()called with notification payload
Debugging push tracking:
B2MetricAnalytics.shared.logLevel = .debug
// Expected output when token is registered:
// [B2Metric] Registering push token
// [B2Metric] push_token event sent
// Expected output when notification opened:
// [B2Metric] Tracking push opened
// [B2Metric] push_opened event sent