iOS 未收到来自 Firebase 云消息传递的通知
iOS not receiving notifications from Firebase Cloud Messaging
我希望推送通知只包含标题。当我从 Firebase 控制台发送消息时,它有效,但当我尝试通过 API 执行相同操作时,它不适用于 iOS(在 Android 上工作正常) .
编辑:我想要完成的是仅在应用未打开时在通知抽屉中显示的通知中显示标题。如果添加了body,它会显示在通知的标题下。
这是我发送的推送通知:
{
"to": "/topics/breaking",
"priority":"high",
"notification": {
"title":"Dette er en test"
}
}
我什么也没得到
如果我在通知中添加body:
{
"to": "/topics/breaking",
"priority":"high",
"notification": {
"title":"Dette er en test",
"body":"hello"
}
}
我在 return
中得到了这个
{
aps = {
alert = {
body = Hello;
title = "Dette er en test";
};
};
"gcm.message_id" = "xxxxxxx";
}
这是打印我收到的内容的代码:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
self.parseNotification(application, userInfo: userInfo as NSDictionary!)
}
func parseNotification(_ application: UIApplication, userInfo: NSDictionary!) {
print(userInfo)
}
如何在不向请求中添加 body 的情况下在 iOS 上获得通知?
我想通了!
如果我删除标题,只有 post body 它有效。
{
"to": "/topics/breaking",
"priority":"high",
"notification": {
"body": "Dette er en test"
}
}
请尝试为推送通知添加证书:用于开发和生产。
我希望推送通知只包含标题。当我从 Firebase 控制台发送消息时,它有效,但当我尝试通过 API 执行相同操作时,它不适用于 iOS(在 Android 上工作正常) .
编辑:我想要完成的是仅在应用未打开时在通知抽屉中显示的通知中显示标题。如果添加了body,它会显示在通知的标题下。
这是我发送的推送通知:
{
"to": "/topics/breaking",
"priority":"high",
"notification": {
"title":"Dette er en test"
}
}
我什么也没得到
如果我在通知中添加body:
{
"to": "/topics/breaking",
"priority":"high",
"notification": {
"title":"Dette er en test",
"body":"hello"
}
}
我在 return
中得到了这个{
aps = {
alert = {
body = Hello;
title = "Dette er en test";
};
};
"gcm.message_id" = "xxxxxxx";
}
这是打印我收到的内容的代码:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
self.parseNotification(application, userInfo: userInfo as NSDictionary!)
}
func parseNotification(_ application: UIApplication, userInfo: NSDictionary!) {
print(userInfo)
}
如何在不向请求中添加 body 的情况下在 iOS 上获得通知?
我想通了!
如果我删除标题,只有 post body 它有效。
{
"to": "/topics/breaking",
"priority":"high",
"notification": {
"body": "Dette er en test"
}
}
请尝试为推送通知添加证书:用于开发和生产。