From 1d287b4d08bba4a8ad29f417d9e64f09711b2a82 Mon Sep 17 00:00:00 2001 From: Marat Alekperov Date: Wed, 18 Mar 2026 17:24:55 +0100 Subject: [PATCH] fix(push): use onNewRegistrationToken instead of activate() on FCM token refresh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling activate() in onNewToken triggers a full device registration flow (CalledActivate state machine event). The correct approach is onNewRegistrationToken, which fires GotPushDeviceDetails — updating the stored token and re-registering with Ably only if the device is already activated. Co-Authored-By: Claude Sonnet 4.6 --- src/pages/docs/push/getting-started/fcm.mdx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/docs/push/getting-started/fcm.mdx b/src/pages/docs/push/getting-started/fcm.mdx index 237d572f9c..72c13328c4 100644 --- a/src/pages/docs/push/getting-started/fcm.mdx +++ b/src/pages/docs/push/getting-started/fcm.mdx @@ -169,6 +169,7 @@ import android.util.Log import androidx.core.app.NotificationCompat import com.google.firebase.messaging.FirebaseMessagingService import com.google.firebase.messaging.RemoteMessage +import io.ably.lib.types.RegistrationToken class PushNotificationService : FirebaseMessagingService() { @@ -180,9 +181,9 @@ class PushNotificationService : FirebaseMessagingService() { override fun onNewToken(token: String) { super.onNewToken(token) Log.d(TAG, "New FCM token received") - // Re-activate push with Ably whenever the FCM token is refreshed try { - AblyHelper.getInstance().push.activate() + // Update the FCM token on Ably server + AblyHelper.getInstance().push.getActivationContext().onNewRegistrationToken(RegistrationToken.Type.FCM, token) } catch (e: Exception) { Log.e(TAG, "Error updating FCM token with Ably", e) }