Skip to content
Push notifications

iOS SDK

Add push notifications

Forward APNs tokens and messenger notifications when customers need replies outside the foreground app.

Add push only when needed

Push is optional. Customer messages and foreground live updates work without APNs. Add push when customers should receive replies while the app is inactive.

Native in-app campaigns can also include a push notification with the same title and message. They reuse the registered APNs device and credentials. The SDK suppresses campaign pushes in the foreground; tapping one opens the app and follows normal cold-launch eligibility. It does not force an older campaign, execute its action, or open a Messenger conversation. For manual notification-response handling, call BTX.handleNotificationResponse(_:) before routing other notifications.

01

Forward the APNs token

When the host app receives a device token, pass it to the messenger facade.

App delegate
func application(
    _ application: UIApplication,
    didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
) {
    Task { @MainActor in
        BTX.messenger.setDeviceToken(deviceToken)
    }
}
02

Handle messenger notifications

If the host app handles remote notifications manually, let BTX inspect the payload first. Non-BTX notifications remain under host-app control.

Remote notification
if BTX.isMessengerNotification(userInfo) {
    Task { @MainActor in
        _ = BTX.messenger.handleRemoteNotification(userInfo)
    }
    completionHandler(.noData)
    return
}
03

Control permission timing

By default, BTX requests notification authorization the first time the messenger is presented. Disable automatic authorization when your app owns the permission prompt and its timing.

Host-owned permission
BTXConfiguration(
    publishableClientKey: "cfk_...",
    messengerOptions: BTXMessengerOptions(
        push: BTXPushConfiguration(
            automaticallyRequestsAuthorization: false
        )
    )
)
  • Enable the messenger capability in BTX configuration.
  • Configure APNs for the host application target.
  • Forward the latest token after APNs registration succeeds.
  • Give BTX only the notifications it recognizes.