Evgeniy Kleban
Evgeniy Kleban

Reputation: 6940

Firebase - invalid token on device on iOS app

I try to implement firebase in my iOS app. I can't get pushes on my device.

For debug I tried to use curl request:

curl --header "Content-Type: application/json" \
--header "Authorization: key=<my key here>" \
https://fcm.googleapis.com/fcm/send \
-d '{"notification": {"body": "Hello from curl via FCM!", "sound": "default"},
"priority": "high",
"to": "<my token here>"}'

If I try to use token that I get, launching app on real device I got following: error:"InvalidRegistration"

If I use token from my Android colleague (or even token I got from launch app on simulator device) I succeed and got something like message id in response.

How to fix that?

Upvotes: 0

Views: 306

Answers (1)

Adeel Ramzan
Adeel Ramzan

Reputation: 41

Your payload seems to be incorrect, try following command in terminal and adjust it as per your requirement:

curl -X POST -H "Authorization: key=<my key here>" -H "Content-Type: application/json" -d '{
  " data ": {
    "title": "Notification title",
    " body ": {
"name": "Body text",
}
  },
  "to": "<my token here>"
}' "https://fcm.googleapis.com/fcm/send"

Upvotes: 1

Related Questions