【问题标题】:How to send a Data Message without notification to ios app?如何在没有通知的情况下向 ios 应用程序发送数据消息?
【发布时间】:2019-04-11 18:34:24
【问题描述】:

我将 Firebase 云消息传递 (FCM) 与 ios 应用程序一起使用。我现在正在尝试使用以下方法获得data message without notification

application(_:didReceiveRemoteNotification:)

我可以使用http://pushtry.com/ 发送数据消息吗?我已尝试从该站点发送数据消息,但没有任何反应,而通知工作正常。

用于数据消息的 JSON

{
  "message":{
    "token":"mytoken comes here",
    "data":{
      "Nick" : "Mario",
      "body" : "great match!",
      "Room" : "PortugalVSDenmark"
    }
  }
}

还有其他网站可以测试data message without notification吗?

【问题讨论】:

  • 您可以在 Firebase 控制台上执行此操作。

标签: ios swift firebase swift3 firebase-cloud-messaging


【解决方案1】:

您可以通过将content_available 作为true 添加到您的有效负载来使用 FCM 发送静默通知。

{
  "message": {
    "token": "mytoken comes here",
    "content_available": true,
    "priority": "high",
    "data": {
      "Nick": "Mario",
      "body": "great match!",
      "Room": "PortugalVSDenmark"
    }
  }
}

【讨论】:

  • 响应:远程服务器返回错误:(400) Bad Request.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-13
相关资源
最近更新 更多