我正在使用新的Firebase平台。我试图通过我的应用服务器发送推送通知并发送到我的iPhone。
我在设置工作的地方手动发送消息与网站上的Firebase通知区域,但是当我尝试将消息发送到https://fcm.googleapis.com/fcm/send时,我没有收到任何消息传递给设备。
我发送以下内容(使用auth标头)
{ "notification": {
"title": "Portugal vs. Denmark",
"text": "5 to 1"
},
"to" : "<registration token>"
}
我收到了来自POST的200个回复,其中包含以下内容:
{
"multicast_id": 5511974093763495964,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1463685441784359%3ad254b53ad254b5"
}
]
}
如果我尝试直接通过Firebase网站发送到此设备,它可以正常工作,但上面的表格帖子没有。不知道从哪里开始!
答案 0 :(得分:32)
在iOS上,priority
字段似乎是强制性的。
{
"to": "cHPpZ_s14EA:APA91bG56znW...",
"priority": "high",
"notification" : {
"body" : "hello!",
"title": "afruz",
"sound": "default"
}
}
答案 1 :(得分:1)
如果API返回message_id
,则表示您的邮件已被正确接受,并且最终将传递给设备。
在Android上,邮件会尽快发送(假设设备已经连接)。
在Apple设备上,如果应用程序已关闭或在后台运行,通知将通过Apple基础架构发送,并可能因Apple文档而相应延迟。
要减少发送到Apple设备的优先级消息的延迟,您可以使用priority
参数。
更多详情:https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message
答案 2 :(得分:1)
我找到了所需的message
字段,以及priority
字段来发送带有POST的邮件。
message
(并标记为可选)。
答案 3 :(得分:0)