如何在不通知的情况下将数据消息发送到ios应用?

时间:2018-11-08 09:11:23

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

我在iOS应用中使用Firebase Cloud Messaging(FCM)。我现在正在尝试使用以下方法获取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吗?

1 个答案:

答案 0 :(得分:0)

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

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