簡體   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