如何使用 Firebase 在 ios 10 中实现丰富的通知

How to implement rich notifications in ios 10 with Firebase

很长一段时间以来,我一直在寻找解决方案。但我找不到任何东西。我已经使用 FCM 实现了 iOS 的推送通知。但是我不知道FCM是否支持iOS 10 rich notifications。如果是这样,我没有找到实现它的代码。提前致谢。

我有同样的问题,为什么 rich notification 不起作用..问题出在 FCM mutable-content payload .. 当 payload 收到时它变成 gcm.notification.mutable-content 这就是问题的原因尚未解决。

更多信息可以查看这个issue from github.

Its resolved now.. you can check that link and also check this AL.

只是与@ElCaptainv2.0 的回答有关的更新。

已为 FCM 添加 mutable_content

Currently for iOS 10+ devices only. On iOS, use this field to represent mutable-content in the APNS payload. When a notification is sent and this is set to true, the content of the notification can be modified before it is displayed, using a Notification Service app extension. This parameter will be ignored for Android and web.

注意:参数值应该是boolean,而不是Integer

几个小时前,kroikie 在 GitHub thread 中也提到了它。

我为此工作了数小时又数小时。除了 rich notification 图片 永远不会显示 ,我的所有通知都工作正常。这是简单的英语答案:

改变这个:

"mutable-content": 1 // 错误

为此:

"mutable_content": true // 正确

这是传出的有效载荷:

"aps": {
    "alert": {
        "title": "Hello",
        "body": "What do you think of this image?"
    },
    "mutable_content": true
},
"media-url": "https://firebasestorage.googleapis.com/....."