<server-key>
JSON Body:
{ "to": "testTopic", "data": { "key1" : "val1", "key2" : true } }
The repsonse in 200 OK but the response body has:
{
"multicast_id": 6098503498585,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results":[
{
"error": "InvalidRegistration"
}
]
}
So the onMessageReceived() is not triggered, neither app in foreground nor in background? Why do I get InvalidRegistration ? What am I missing?
The server key at point 3 is from Firebase Project settings --> Cloud messaging --> Server key
FCM can send a notification message including an optional data payload. In such cases, FCM handles displaying the notification payload, and the client app handles the data payload. For testing or for marketing and user re-engagement, you can send notification messages using the Firebase console .
Join us for Firebase Summit on November 10, 2021. Tune in to learn how Firebase can help you accelerate app development, release with confidence, and scale with ease. Register Firebase Cloud Messaging (FCM) offers a broad range of messaging options and capabilities.
Use data messages when you want to process the messages on your client app. FCM can send a notification message including an optional data payload. In such cases, FCM handles displaying the notification payload, and the client app handles the data payload.
FCM does not provide an end-to-end solution. However, there are external solutions available such as Capillary or DTLS. Both programmatically or via the Firebase console, you can send notification messages that contain an optional payload of custom key-value pairs. In the Notifications composer, use the Custom data fields in Advanced options.
In 4. your JSON requires a preceeding
/topics/
for "to" thus:
{ "to": "/topics/testTopic",....}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With