适用于 iOS 的 FCM 丰富推送通知负载 [英] FCM rich push notification payload for iOS

查看:37
本文介绍了适用于 iOS 的 FCM 丰富推送通知负载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的项目使用 FCM.它具有丰富的类型推送通知.我尝试修改大多数可能的方式来从 FCM 获取推送.我得到了来自 FCM 的普通推送,而不是图片.

I am using FCM for my project. It's have rich push notification for a type. I tried to modified most of possible ways to get push from FCM. I got obly ordinary push from FCM, not with image.

我还使用 push try 来检查 APNS 相同的编码.我得到了推送通知的预期设计.

I am also check with APNS same coding using push try. I got what expected design for push notification.

这是我的 APNS 有效负载

{
  "aps": {
     "alert": "Enter your message",
     "badge": 1,
     "sound": "default",
     "content-available": 1,
     "mutable-content": 1
  },
  "mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
}

这里FCM有效载荷

{
   "to": "dWB537Nz1GA:APA91bHIjJ5....",
   "data":
   {
      "message": "Offer!",
      "mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
   },
   "notification":
   {
      "body": "Enter your message",
      "sound": "default",
      "content-available": 1,
      "mutable-content": 1
   }
}

我还需要类别 更多详情FCM中的有效载荷

我是否遗漏了 fire-base 控制台中的任何设置,或者是来自有效负载的设置.

Am I missing any setting in fire-base console or is that from payload.

推荐答案

您的 FCM 负载中的 mutable-contentcontent-available 不正确.它应该被格式化为 mutable_contentcontent_available.两者都是 boolean 并且还必须在 notification 参数之外.像这样:

The mutable-content and content-available in your FCM payload is incorrect. It should be formatted as mutable_content and content_available. Both are boolean and must also be outside the notification parameter. Like so:

{
   "to": "dWB537Nz1GA:APA91bHIjJ5....",
   "content_available": true,
   "mutable_content": true,
   "data":
   {
      "message": "Offer!",
      "mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
   },
   "notification":
   {
      "body": "Enter your message",
      "sound": "default"
   }
}

对于 FCM 中 category 的对应项,您应该使用 click_action:

For the counterpart of category in FCM, you should use click_action:

与用户点击通知相关的操作.

The action associated with a user click on the notification.

对应于 APNs 负载中的 category.

Corresponds to category in the APNs payload.

这篇关于适用于 iOS 的 FCM 丰富推送通知负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆