registerDevice

abstract suspend fun registerDevice(context: Context, deviceToken: String): Result<Unit>

Registers this device for push notifications using the provided FCM device token.

Call this method after receiving a token from Firebase Cloud Messaging (e.g., in FirebaseMessagingService.onNewToken). This makes the registration call to the server immediately. No action occurs if the same token has already been registered.

Unlike the static CoreClient.provideDeviceToken method, which stores the token locally and defers registration until the first network request (e.g., creating a conversation or sending a message), this method registers immediately.

Return

Result.Success on successful registration, or Result.Error on failure.

Parameters

context

The application Context.

deviceToken

The FCM device token to register.

Samples

// In your FirebaseMessagingService.onNewToken callback, register the
// token with the SDK. Unlike CoreClient.provideDeviceToken (static),
// registerDevice makes the registration call to the server immediately.
val fcmToken = "token-from-onNewToken"
coreClient.registerDevice(context, fcmToken)