【发布时间】:2016-10-30 04:00:54
【问题描述】:
我正在尝试让 Firebase Cloud Messaging iOS 警报从我的服务器发送到 FCM,以显示在我的 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;
}
...但如果我试试这个:
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\"}}"
...无论 FCM 示例应用程序是在前台、后台还是完全关闭,它都不会显示为警报。
它确实会显示在 iOS 控制台中,但参数较少:
{
aps = {
alert = "HEY YO";
};
"gcm.message_id" = "0:123456789_blah_blah";
}
是否可以使用 curl 触发在我的 iOS 设备上显示为警报的 Firebase 云消息传递通知?
回答 [thanx 2 Arthur!]:
只需添加:\"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\"}}"
...我看到一个漂亮的警报通知!!!
【问题讨论】:
标签: ios curl google-cloud-messaging apple-push-notifications firebase-cloud-messaging