Karel Krýda
Karel Krýda

Reputation: 107

FirebaseInstanceIdService does not exist

I'm creating a chat app and according to the tutorial I should create this: Tutorial example

The problem is that nowadays this function (FirebaseInstanceIdService) no longer exists and therefore I cannot use it. Would anyone advise me with what code to achieve the same result? Thank you

Upvotes: 3

Views: 786

Answers (2)

Thida Swe Zin
Thida Swe Zin

Reputation: 309

Within the class extending FirebaseMessagingService, in which you are already overriding onMessageReceived() method, override the onNewToken(token: String) method (this replaces the old onTokenRefresh(), so all the logic you had there, must be put here). With Kotlin,

override fun onMessageReceived(remoteMessage: RemoteMessage) {
    //the logic here
}

override fun onNewToken(token: String) {
    //all the logic of the old FirebaseInstanceIdService.onTokenRefresh() here
    //usually, to send to the app server the instance ID token
    sendTokenToTheAppServer(token)
}

Upvotes: 0

JakeB
JakeB

Reputation: 2113

FirebaseInstanceIdService has been depracated and replaced with FirebaseMessagingService

https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceIdService

onTokenRefresh is now onNewToken.

Upvotes: 2

Related Questions