I can't send firebase cloud messages #317
-
I want to send cloud message with Esp8266. I want to send to all devices without adding device token. I just added the FCM server key to the arduino code. But it didn't work. #define API_KEY "These parts are actually full." #include <ESP8266WiFi.h> FirebaseData fbdo; void setup() { void loop() { void sendMessage()
} it keeps giving Send message... unknown error. All I want is to send messages like in the cloud message interface. automatically to all devices. Without using the device token. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
When you set the topic using Both Without device token adding, |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I don't know why you call sendTopic twice Firebase.sendTopic(fbdo); <---- ?? |
Beta Was this translation helpful? Give feedback.
-
As you will see from example, function Serial.printf("Send message... %s\n", Firebase.sendTopic(fbdo) ? "ok" : fbdo.errorReason().c_str()); Or for better reading if (Firebase.sendTopic(fbdo))
{
Serial.println("Send message... ok");
}
else
{
Serial.print("Send message... ");
Serial.println(fbdo.errorReason());
}
This is where to find FCM Server key You heed to create mobile app or web app that installed the Firebase SDK and registered to your project to get notification message. If you still can't send the message, you should try to create new project and try again. |
Beta Was this translation helpful? Give feedback.
-
As already stated in example comment, where to get start the FCM app. Firebase-ESP8266/examples/Messaging/Messaging.ino Lines 25 to 28 in cf26633 The FCM required real device with registered app. |
Beta Was this translation helpful? Give feedback.
When you set the topic using
fbdo.fcm.setTopic
, it works only forFirebase.sendTopic
.Both
Firebase.sendMessage
andFirebase.broadcastMessage
required device token to send message to, callingfbdo.fcm.addDeviceToken
to add device token.Without device token adding,
Firebase.sendMessage
will give "unknown error" andFirebase.broadcastMessage
will give "bad request".