ox.*_*ox. 10 curl apple-push-notifications ios google-cloud-messaging firebase-cloud-messaging
我正在尝试将从我的服务器发送到FCM的Firebase Cloud Messaging iOS警报显示在我的iOS设备上.
如果我从FCM控制台发送消息:
https://console.firebase.google.com/project/ your-awesome-project/notification
和FCM示例应用程序:
https://github.com/firebase/quickstart-ios
关闭或在后台,警报显示美妙,
如果它在前台我在iOS控制台中看到这个:
{
aps = {
alert = "HEY YO";
};
"gcm.message_id" = "0:123456789_blah_blah";
"gcm.n.e" = 1;
"google.c.a.c_id" = 123XXXXXXXX789;
"google.c.a.e" = 1;
"google.c.a.ts" = 123XXX789;
"google.c.a.udt" = 0;
}
Run Code Online (Sandbox Code Playgroud)
......但如果我试试这个:
curl -X POST
--header "Authorization: key=<server key>"
--header "Content-Type: application/json"
https://fcm.googleapis.com/fcm/send
-d "{\"to\":\"<device registration id>\",\"notification\":{\"body\": \"HEY YO\"}}"
Run Code Online (Sandbox Code Playgroud)
...无论FCM示例应用程序是在前台,后台还是完全关闭,它都不会显示为警报.
然而它确实出现在iOS控制台中,但参数较少:
{
aps = {
alert = "HEY YO";
};
"gcm.message_id" = "0:123456789_blah_blah";
}
Run Code Online (Sandbox Code Playgroud)
是否可以使用curl触发在我的iOS设备上显示为警报的Firebase云消息通知?
答案 [感谢亚瑟!] :
只需添加: \"priority\":\"high\"
像这样:
curl -X POST
--header "Authorization: key=<server key>"
--header "Content-Type: application/json"
https://fcm.googleapis.com/fcm/send
-d "{\"to\":\"<device registration id>\",\"priority\":\"high\",\"notification\":{\"body\": \"HEY YO\"}}"
Run Code Online (Sandbox Code Playgroud)
......我看到一个美丽的警报通知!