Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/pages/docs/push/getting-started/fcm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -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)
}
Expand Down
Loading