Ralf Wickum
Ralf Wickum

Reputation: 3294

InvalidRegistration when sending Firebase data messages with https://fcm.googleapis.com/fcm/send?

  1. I setup a REST client with POST --> https://fcm.googleapis.com/fcm/send
  2. Content-Type : application/json
  3. Authorization : key=<server-key>
  4. 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

Upvotes: 6

Views: 4959

Answers (1)

Murat Ceven
Murat Ceven

Reputation: 264

In 4. your JSON requires a preceeding

/topics/

for "to" thus:

{ "to": "/topics/testTopic",....}

Upvotes: 7

Related Questions