Closed blacxcode closed 4 years ago
If firebaseFCM is FirebaseData object.
To clear all device tokens. firebaseFCM.fcm.clearDeviceToken();
To get the sending error. firebaseFCM.errorReason();
To send a message to a recipient, you need to provide the index of device token which should not greater than the number of device tokens you 've added minus one otherwise the error will occur.
Add and remove device tokens are just adding and removing data from a dynamic array of string.
It is simple as you use std::vector<String>
in C++.
And make sure you send messages to existent users or devices (tokens).
I've checked, the problem is that token sent from the device is invalid. Thanks, Bro
How to implement remove device token after sending a message? I used this code but not send any more for the next user. I've got the error message "error":"InvalidRegistration"
define FIREBASE_FCM_SERVER_KEY "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
define MAX_USER 100
define MAX_DEVICE 10
FirebaseData firebaseFCM;
String mUser[MAX_USER]; String mTokenDevice[MAX_DEVICE]; String mTitle = "This is title"; String mBody = "This is body" String mDataMessage = "{" "\"data\" : {" "\"title\" : \"" + mTitle + "\"," "\"body\" : \"" + mBody + "\"" "} }"
for (int z = 0; z < MAX_USER; z++) { if (mUser[z] == "") break;
}