B Bubbl Docs

Notifications (iOS)

Notification data flow

  1. APNs delivers payload
  2. Firebase Messaging resolves token + delivery callbacks
  3. NotificationManager.shared handles notification details
  4. Your app presents the modal and tracks engagement events
UNUserNotificationCenter.current().delegate = NotificationManager.shared
Messaging.messaging().delegate = self

Forward system callbacks

func userNotificationCenter(
  _ center: UNUserNotificationCenter,
  willPresent notification: UNNotification,
  withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
) {
  NotificationManager.shared.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
}

func userNotificationCenter(
  _ center: UNUserNotificationCenter,
  didReceive response: UNNotificationResponse,
  withCompletionHandler completionHandler: @escaping () -> Void
) {
  NotificationManager.shared.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
}

Build modal from SDK details

@ObservedObject private var notificationManager = NotificationManager.shared

.sheet(item: $notificationManager.latest) { details in
  NotificationModalView(details: details)
}

Track interactions

NotificationManager.shared.trackCTAEngagement(notificationID: notifId, locationID: locationId)
NotificationManager.shared.trackMediaView(notificationID: notifId, locationID: locationId)

BubblPlugin.shared.trackSurveyEvent(
  notificationId: "\(notifId)",
  locationId: "\(locationId)",
  activity: "dismissed"
) { _ in }