繁体   English   中英

Firebase-iOS应用上设备上的无效令牌

[英]Firebase - invalid token on device on iOS app

我尝试在我的iOS应用中实现Firebase。 我无法在设备上进行推送。

对于调试,我尝试使用curl请求:

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>"}'

如果我尝试使用获得的令牌,则在真实设备上启动应用程序,我得到以下消息:错误:“ InvalidRegistration”

如果我使用来自我的Android同事的令牌(甚至是我从模拟器设备上的启动应用程序获得的令牌),则我会成功,并且得到诸如消息ID之类的信息作为响应。

如何解决?

您的有效负载似乎不正确,请在终端中尝试以下命令并根据需要进行调整:

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"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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