当我尝试在Android上发送通知时,代码工作正常,但不适用于IOS通知。出现以下错误:
{
"results": [
{
"error": {
"code": "messaging/internal-error",
"message": "An internal error has occurred. Please retry the request."
}
}
],
"canonicalRegistrationTokenCount": 0,
"failureCount": 1,
"successCount": 0,
"multicastId": 8118740071861272000
}
这是我的代码示例,请看一下并帮助我解决问题。 另外,当我尝试从云消息控制台发送通知时,也会收到通知。
return await admin.messaging()
.sendToDevice(deviceToken, {
data: {
title: 'Test Fcm',
body: 'tesing fmc body',
content_available: 'true',
priority: 'high',
action_type: 'TEST'
},
notification: {
title: 'Test Fcm',
body: 'tesing fmc body',
content_available: 'true',
priority: 'high'
}
}
, {
priority: "high",
timeToLive: 60 * 60 * 24,
contentAvailable:true,
}).catch(err => {
console.log(err);
})
答案 0 :(得分:0)
我在2天前遇到过此问题。
只需从“通知”中删除“ content_available”,即可使用。
您的json的示例=>
{
data: {
title: 'Test Fcm',
body: 'tesing fmc body',
content_available: 'true',
priority: 'high',
action_type: 'TEST'
},
notification: {
title: 'Test Fcm',
body: 'tesing fmc body',
=> content_available: 'true', // remove this
priority: 'high'
}
}
致谢。