【问题标题】:Fcm: Send DataMessage to Android and IOS when app is in background and in foregroundFcm:当应用程序处于后台和前台时,向 Android 和 IOS 发送 DataMessage
【发布时间】:2017-04-11 12:40:36
【问题描述】:

我正在实现我的自定义 FCM 服务器以向 Android 和 IOS 设备发送通知。 我需要使用 DataMessage 向两个操作系统发送自定义键值对,我的数据消息类似于:

{
  "content_available": true,
  "data": {
    "lan": "IT",
    "messageId": "67",
    "message": "test message"
  },
  "registration_ids": [
    "..."
  ],
  "priority": "high"
}

当应用程序处于前台和后台时,Android 会正确接收通知。 IOS 仅在应用程序处于前台时接收数据。 怎么了?

【问题讨论】:

  • 尝试将“content_available”更改为“content-available”
  • 如文档所述,“content_available”是正确的

标签: android ios firebase push-notification firebase-cloud-messaging


【解决方案1】:

我为同样的事情而努力,试图让它同时在 Android 和 iOS 上运行。事实证明你不能。

在Android中,如果是数据负载,它会在后台工作,通知负载不会在后台工作。

在 iOS 中,如果您发送通知负载,那么它会在后台运行,但数据负载不会在后台运行。 See this issue for more info

似乎您必须为另一个平台牺牲一个平台。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-19
    • 1970-01-01
    • 2018-07-31
    • 1970-01-01
    • 2021-03-10
    • 2019-06-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多