简体   繁体   中英

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?

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM