Skip to main content

Troubleshooting

SDK Not Initializing

Problem: SDK throws errors or events aren't being sent.

Solution:

  1. Verify API key is not empty
  2. Enable debug logging:
B2MetricAnalytics.shared.logLevel = .debug
B2MetricAnalytics.shared.start(apiKey: "YOUR_API_KEY")
  1. Check Xcode console output for errors

Events Not Appearing

Problem: You're tracking events but don't see them in the dashboard.

Common causes:

  1. Events still in queue — For testing, send events immediately:
B2MetricAnalytics.shared.start(
apiKey: "YOUR_API_KEY",
batchSize: 1, // Send immediately
flushInterval: 5
)
  1. No internet connection — Events are stored locally when offline and sent when connection is restored.

  2. 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
  • didRegisterForRemoteNotificationsWithDeviceToken implemented
  • registerDeviceToken() called with device token
  • didReceiveRemoteNotification implemented
  • 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