[英]iOS not receiving notifications from Firebase Cloud Messaging
I want the push notification to only contain the title. 我希望推送通知仅包含标题。 When I send a message from the Firebase console, it works, but when I try to do the same via the API, it doesn't work for iOS (works fine on Android).
当我从Firebase控制台发送消息时,它可以工作,但是当我尝试通过API进行操作时,它不适用于iOS(在Android上工作正常)。
Edit: What I'm trying to accomplish is to only show the title in the notification that shows up in the notification drawer when the app is not open. 编辑:我要完成的是仅在未打开应用程序时在通知抽屉中显示的通知中显示标题。 If body is added, it is shown under the title in the notification.
如果添加了正文,则它将显示在通知的标题下。
This is the push notification I'm sending: 这是我发送的推送通知:
{
"to": "/topics/breaking",
"priority":"high",
"notification": {
"title":"Dette er en test"
}
}
And I get nothing back 我什么也没回来
If I add body to the notification: 如果我在通知中添加正文:
{
"to": "/topics/breaking",
"priority":"high",
"notification": {
"title":"Dette er en test",
"body":"hello"
}
}
I get this in return 我得到这个回报
{
aps = {
alert = {
body = Hello;
title = "Dette er en test";
};
};
"gcm.message_id" = "xxxxxxx";
}
Here is the code to print out what I receive: 这是打印我收到的代码:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
self.parseNotification(application, userInfo: userInfo as NSDictionary!)
}
func parseNotification(_ application: UIApplication, userInfo: NSDictionary!) {
print(userInfo)
}
How can I get the notification on iOS without adding body to the request? 如何在iOS上获取通知而无需在请求中添加正文?
I figured it out! 我想到了!
If I drop the title and ONLY post body it works. 如果我放下标题并仅张贴正文,则可以使用。
{
"to": "/topics/breaking",
"priority":"high",
"notification": {
"body": "Dette er en test"
}
}
请尝试添加用于推送通知的证书:用于开发和生产。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.