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.

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.