setPushToken

Registers the device's Firebase Cloud Messaging (FCM) token with Superwall, so Superwall can send it push notifications.

Call this from your FirebaseMessagingService.onNewToken, and with FirebaseMessaging.getInstance().token when your app starts. It's safe to call on every launch: an unchanged token is only sent again once a day, to tell Superwall the device is still registered.

Call configure first: Superwall.instance throws until it has been called. If onNewToken can run before your app configures Superwall, for example when the service starts in the background, keep the token and pass it in once you've configured.

override fun onNewToken(token: String) {
Superwall.instance.setPushToken(token)
}

The token only travels to Superwall's servers. It never appears in SuperwallDelegate.handleSuperwallEvent, SuperwallDelegate.handleLog, user attributes or audience filters. Along with it, Superwall receives whether the app can post notifications, which is checked again each time the app comes to the foreground.

The SDK has no Firebase dependency and doesn't request notification permission itself.

Parameters

token

The FCM registration token.