gpt4 book ai didi

ios - 尽管存在有效的 P8 APNs Auth Key,但 Firebase 云消息传递返回 InvalidApnsCredential

转载 作者:行者123 更新时间:2023-12-04 04:27:55 25 4
gpt4 key购买 nike

我正在尝试使用 Firebase Cloud Messaging 向 IOS 设备发送通知 - Firebase 控制台中的每个 IOS 项目都有一个有效的 APNs P8 Auth Key,它是为此目的从 Apple 开发人员帐户新生成的。

我正在使用这种方法:

curl -X POST \
https://fcm.googleapis.com/fcm/send \
-H 'Authorization: key=<My Key>' \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"to": "<Device Token>",
"notification": {
"title": "Push Notification Test to IOS",
"body":"Push Notification Test to IOS"
},
"data": {
"message": "Push Notification Test to IOS"
}
}'

这会导致 FCM 出现以下错误:
{
"multicast_id": <Id>,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
{
"error": "InvalidApnsCredential"
}
]
}

如果我从消息中删除“通知” block ,FCM 会成功响应,但设备上没有收到任何内容。

我可以使用上面的示例消息发送和接收通知
安卓设备就好了。

FCM documentation建议当包含“通知” block 时,当 token 用于 IOS 设备时,FCM 会尝试通过 APNs 发送:

If a notification payload is provided, or the content_available option is set to true for a message to an iOS device, the message is sent through APNs, otherwise it is sent through the FCM connection server.



我试过的:
  • 刷新 token
  • 等待 24 小时让 token 在 APN 和 FCM 服务器环境中传播
  • 使用 P12 证书
  • 使用 P8 证书
  • 确保 IOS 应用程序允许 Xcode 中的通知
  • 确保 Apple Developer 帐户的应用程序允许通知
  • 确保 plist、FCM 和 Apple 帐户中的 Bundle Id 是正确的
  • 尝试了 FCM 旧 key 和服务器 key
  • 最佳答案

    InvalidApnsCredential并不意味着问题与 APNS 证书或 key 直接相关。
    在我的情况下,我遇到了一个带有白色标签的应用程序的问题,经过调查,我发现我的应用程序包 ID (PRODUCT_BUNDLE_IDENTIFIER) 与 Firebase 中的不匹配(我使用的是开发包 ID 而不是生产包 ID)。

    关于ios - 尽管存在有效的 P8 APNs Auth Key,但 Firebase 云消息传递返回 InvalidApnsCredential,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53822811/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com