Firebase API call with multiple topics in condition

拜拜、爱过 提交于 2019-12-23 11:56:50

问题


I am facing a tragic issue while calling FCM API:- In brief When I am calling the API with following:

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"
    }
}

It works Fine and I got the notification on device from which I have subscribed to topic "Software", But when I go for multiple topics and change the body to

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

then I don't get the notification I have tested it on POSTMAN it shows that message was sent but I don't receive any notification on my device.


回答1:


This is the right way as per the Firebase Documentation:

Topic HTTP POST request

Send to a single topic:

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!",
   }
}

Send to devices subscribed to topics "dogs" or "cats":

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!",
   }
}


来源:https://stackoverflow.com/questions/41800879/firebase-api-call-with-multiple-topics-in-condition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!