Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase API call with multiple topics in condition

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.

like image 642
Nil Avatar asked Jan 23 '17 07:01

Nil


1 Answers

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!",
   }
}
like image 186
Darush Avatar answered Oct 19 '22 02:10

Darush