简体   繁体   English

iOS未从Firebase Cloud Messaging接收通知

[英]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.

相关问题 在 ios 中未收到 Firebase 云消息传递通知 - Not receiving Firebase Cloud Messaging Notifications in ios Google Cloud Messaging iOS,接收多个通知 - Google Cloud Messaging iOS, receiving multiple notifications Firebase 云消息未收到通知 (iOS) - Firebase Cloud Messaging Not Receiving Notification (iOS) 不会使用Firebase云消息传递的Swift迅速向iPhone接收通知 - Notifications aren't receiving to iPhone using swift from firebase cloud messaging ios Google Cloud Messaging(GCM)未收到远程通知 - ios Google Cloud Messaging (GCM) not receiving remote notifications iOS Firebase消息未收到 - iOS Firebase messaging not receiving 适用于iOS的Firebase云消息传递:不接收来自POST请求的通知(仅来自作曲家工具) - Firebase cloud messaging for iOS: don't receive notifications from POST request (only from composer tool) iOS的Firebase Cloud Messaging通知未显示打开和分析 - Firebase Cloud Messaging Notifications for iOS not showing opened and analytics FCM 检测 IOS 上的应用程序卸载(firebase 云消息推送通知) - FCM detect app uninstall on IOS (firebase cloud messaging push notifications) iOS 设备上未显示 Firebase 云消息传递通知(前台和后台) - Firebase Cloud Messaging notifications not being displayed on iOS device (foreground and background)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM