Home > front end >  cannot find symbol class FirebaseInstanceId in my android studio project
cannot find symbol class FirebaseInstanceId in my android studio project

Time:11-24

import com.google.firebase.iid.FirebaseInstanceId; ^ symbol: class FirebaseInstanceId location: package com.google.firebase.iid

The code is in my RNPushNotifications.java file and I have tried changing multiple versions of firebase core and messaging, but nothing seems to help.

PS: also tried solutions given in Cannot resolve symbol "FirebaseInstanceId"

CodePudding user response:

This method and class is deprecated in the latest versions,now you can use FirebaseMessaging class to get the Device token, like this

      FirebaseMessaging.getInstance().getToken()
            .addOnCompleteListener(task -> {
                if (task.isSuccessful() && task.getResult() != null) {
                    sendFCMTokenToDatabase(task.getResult());
                }
            });

Here task.getResult() method will provide you with FCM token.

  • Related