setFirebaseCloudMessagingToken

open fun setFirebaseCloudMessagingToken(@NotNull context: @NotNull Context, token: String)

Stores the Firebase Cloud Messaging token for push notifications.

Important: This method must be called:

  • Initially: When your app receives its first FCM token (typically in your FirebaseMessagingService.onNewToken())
  • On Refresh: Every time FCM provides a new token (tokens can be rotated by Firebase)

Once provided, the token will be used for push notifications until it expires or is refreshed by Firebase. The SDK automatically handles token registration with Help Scout when users are identified.

Example usage:


public class MyFirebaseMessagingService extends FirebaseMessagingService {
    
    public void onNewToken(String token) {
        // This is called whenever FCM provides a new or refreshed token
        Beacon.setFirebaseCloudMessagingToken(this, token);
    }
}

Parameters

context

The application context

token

The FCM token to store (must not be null or empty)

Throws

if the token is null or empty