【发布时间】:2021-10-30 12:16:51
【问题描述】:
我正在使用 Flutter 和 Firebase 编写一个跨平台应用程序。我一直在努力发送通知,它在 android 上运行良好。我通过firebase管理功能sdk发送消息没有问题。请求如下所示:
const payload = {
notification: {
title: title,
body: body,
},
}
return admin.messaging().sendToDevice(tokens, payload, {
mutableContent: true,
contentAvailable: true,
apnsPushType: "background",
})
但是当我尝试向 iOS 设备发送消息时,我从 shell 收到以下错误:
"error": {
"errorInfo": {
"code": "messaging/third-party-auth-error",
"message": "A message targeted to an iOS device could not be sent
the required APNs SSL certificate was not uploaded or
has expired. Check the validity of your development and
production certificates."
},
"codePrefix": "messaging"
}
我的印象是,由于我使用的是在苹果开发者控制台中生成的 APNs 密钥,因此我不需要任何类型的 SSL 证书。我的密钥已上传到 Firebase 控制台,并且 iOS 设备正在成功报告其设备令牌,所以我不确定为什么我无法收到消息。
我已尝试从 CLI 和 FCM 控制台在线发送消息。两者都失败了。 我还通过后台获取和远程通知启用了推送通知和后台模式。
任何帮助或建议将不胜感激。
【问题讨论】:
-
您是否以this thread said 生成了APNS 认证?
-
原来这不是问题所在。坦率地说,我不确定 .pem 文件的用途。 Firebase 现在支持 .p12 文件作为 auth 密钥,所以也许这在某一时刻很有用,但现在可能已经过时了。无论如何感谢您的帮助! @AechoLiu
标签: ios firebase flutter firebase-cloud-messaging firebase-admin