我正在使用Flutter和Firebase编写跨平台应用程序。我一直在研究如何发送通知,在安卓上已经能够完美地实现了。我通过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在线控制台发送消息。 两者都失败了。 我还启用了推送通知和后台模式,包括后台获取和远程通知。
如有帮助或建议,将不胜感激。