具有多个主题的Firebase API调用

时间:2017-01-23 07:05:23

标签: android firebase google-cloud-messaging firebase-cloud-messaging

我在调用FCM API时面临一个悲剧性的问题: - 简而言之当我使用以下内容调用API时:

URL:-https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AAAA4Kkj8iw:APA91bE......vE4Hxg
{
    "condition" : "'Software' in topics",
    "data":{
        "title":"Title",
        "message":"Hello,Via Multiple Topics"
    }
}

它工作正常,我在设备上收到了通知,我已经订阅了主题"软件",但当我选择多个主题并将主体更改为

{
    "condition" : "'Software' in topics || 'IOT' in topics",
    "data":{
        "title":"Title",
        "message":"Hello,Via Multiple Topics"
    }
}

然后我没有收到通知 我在POSTMAN上测试过它显示邮件已发送但我在设备上没有收到任何通知。

1 个答案:

答案 0 :(得分:0)

根据Firebase Documentation

,这是正确的方法

主题HTTP POST请求

发送到一个主题:

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
  "to": "/topics/foo-bar",
  "data": {
    "message": "This is a Firebase Cloud Messaging Topic Message!",
   }
}

发送给订阅主题为“狗”或“猫”的设备:

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
  "condition": "'dogs' in topics || 'cats' in topics",
  "data": {
    "message": "This is a Firebase Cloud Messaging Topic Message!",
   }
}