Firebase API调用的条件中有多个主题 [英] Firebase API call with multiple topics in condition

查看:352
本文介绍了Firebase API调用的条件中有多个主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在调用FCM API时遇到了一个悲剧性问题: -
简而言之当我使用以下方法调用API时:

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

然后我没有收到通知
我在POSTMAN上测试过它显示消息已发送但我不知道将收不到我的设备上的任何通知。

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.

推荐答案

这是根据 Firebase Documentation
$ b

主题HTTP POST请求



发送到单个主题:



This is the right way as per the Firebase Documentation:

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

这篇关于Firebase API调用的条件中有多个主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆