mobizt / Firebase-ESP32

[DEPRECATED]🔥 Firebase RTDB Arduino Library for ESP32. The complete, fast, secured and reliable Firebase Arduino client library that supports CRUD (create, read, update, delete) and Stream operations.
MIT License
415 stars 118 forks source link

Invalid token in FCM firebase #203

Closed razisek closed 2 years ago

razisek commented 2 years ago

I want to use Firebase Cloud Messaging (FCM). but when entering Server key from cloud messaging in firebase I get response :

The ID token or registration token was not not found at index
The ID token or registration token was not not found at index
The ID token or registration token was not not found at index

the server key I use is the same as the one in the firebase console image this my method :

void sendNotification()
    {
        fbdo.fcm.begin("AAAAJn7rcU0:APA91bECX7dFufaRYc9LzLbSXmIQCFpqmHiJnhg9_h-Mk2W03gaSWPeUmZTxw5235Caqcchm36tyeblsDSFLHyZEfmrA0w9gjTrWtLG6mdprG7tUw8tOUn64ak4W2Emk_Zxxxxxxxxx");
        fbdo.fcm.addDeviceToken("fh3SkcqSTFK7zhmjalPS7f:APA91bGeLJG5gtsNIFU4qsf7uiZchQi9-ZkvQlvJZr_cj6fKr1LGYY8rnoqH7iCRLgg7ZQmKFgCYKM5EmGsiK8c5ovXcLNvCrI9kp3ygoTiYEeOX0TudBkZPw-i83-xxxxxxxxxxxx");
        fbdo.fcm.setPriority("normal");
        fbdo.fcm.setTimeToLive(5000);
        fbdo.fcm.setNotifyMessage("Notification", "Hello World!", "firebase-logo.png", "http://www.google.com");
        fbdo.fcm.setDataMessage("{\"myData\":\"myValue\"}");
        if (Firebase.sendMessage(fbdo, 1))
        {
            //Success, print the result returned from server
            Serial.println(fbdo.fcm.getSendResult());
        }
        else
        {
            //Failed, print the error reason
            Serial.println(fbdo.errorReason());
        }
    }

can anyone help? thanks

mobizt commented 2 years ago

The index in sendMessage started at 0 and you just add only one token using addDeviceToken.

razisek commented 2 years ago

how to send to multiple device?

mobizt commented 2 years ago

Add more tokens and use broadcast.

https://github.com/mobizt/Firebase-ESP32/blob/150be42799b5602a12103db8985b0cdd620b4c69/examples/Messaging/Messaging.ino#L100

razisek commented 2 years ago

thankss sir