Messaging

interface Messaging

Messaging feature — register and manage push-notification tokens.

Consumer apps handle their own Firebase setup and obtain the FCM registration token themselves (on iOS, Firebase Messaging turns the APNs device token into an FCM token). Use this interface to share that token with the AFCore backend, which sends through FCM. The token only works with the Firebase project that issued it.

Typical flow

  1. After sign-in, get the FCM registration token from Firebase Messaging.

  2. Call updateToken with the token and a device identifier that is stable and unique per install. Call it again whenever Firebase rotates the token.

  3. Call deleteToken when the member turns push off. authentication().logout() removes the last registration itself before it ends the session - best effort, and only while the access token is still valid. Call deleteToken before logout() when the removal must happen, and before a different member signs in without logout(), which ends the session without removing it.

The registration also carries the device platform and app version. AFCore never calls Firebase and never registers a token on its own.

Functions

Link copied to clipboard
abstract suspend fun deleteToken(deviceId: String): Boolean

Removes the device’s push-notification association on the backend.

Link copied to clipboard
abstract suspend fun getToken(): String?

Retrieves the FCM token the backend holds for the signed-in member.

Link copied to clipboard
abstract suspend fun updateToken(token: String, deviceId: String): Boolean

Stores this install's FCM registration token for the signed-in member.