Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FirebaseInstanceIdService is deprecated #1

Open
nigel12341 opened this issue Aug 31, 2018 · 2 comments
Open

FirebaseInstanceIdService is deprecated #1

nigel12341 opened this issue Aug 31, 2018 · 2 comments

Comments

@nigel12341
Copy link

'FirebaseInstanceIdService' is deprecated. Deprecated in Java

@amonkhepri
Copy link

Try updating gradle Firebase related implementations to current version

//firebase
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-firestore:18.2.0'
implementation 'com.google.firebase:firebase-auth:16.2.1'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
implementation 'com.google.firebase:firebase-storage:16.1.0'
implementation 'com.firebaseui:firebase-ui-storage:3.3.1'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.6.0'

@nocturnalbeast
Copy link

This is because FirebaseInstanceIdService has been replaced by FirebaseMessagingService.

You'll need to update your build.gradle files in the app folder to reflect the newer versions first, like @Amunratis has mentioned.

    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-firestore:20.1.0'
    implementation 'com.google.firebase:firebase-auth:18.0.0'
    implementation 'com.firebaseui:firebase-ui-auth:3.3.1'
    implementation 'com.google.firebase:firebase-storage:18.0.0'
    implementation 'com.firebaseui:firebase-ui-storage:3.3.1'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
    implementation 'com.google.firebase:firebase-messaging:19.0.1'

This is just similar to what he has mentioned, but the main modules you must upgrade are the core and the messaging modules.

After doing so, you'll need to modify the MyFirebaseInstanceIDService class by making it inherit the FirebaseMessagingService instead of the FirebaseInstanceIdService like so:

class MyFirebaseInstanceIDService : FirebaseMessagingService() {

Then replace the onTokenRefresh() function with the onNewToken() as given below:

    override fun onNewToken(token: String) {
        super.onNewToken(token)
        if (FirebaseAuth.getInstance().currentUser != null)
            addTokenToFirestore(token)
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants