How to send firebase notifications to audience via

2019-01-09 02:05发布

In Firebase Console I set up audiences based on various user properties and now am able to send notifications to different user segments via console. Is there a way to do the same by http requests to fcm servers? There should be a trick with "to" field, but I couldn't figure it out.

4条回答
家丑人穷心不美
2楼-- · 2019-01-09 02:21

firebaser here

There is currently no way to send a notification to a user segment programmatically. It can only be done from the Firebase Console as you've found.

We're aware that allowing this through an API would expand the potential for Firebase Notifications a lot. So we're considering adding it to the API. But as usual: no commitment and no timelines, since those tend to change as priorities shift.

查看更多
看我几分像从前
3楼-- · 2019-01-09 02:27

This has been a popular request, but unfortunately it is not yet possible. We are looking into this. Please check Firebase Cloud Messaging announcements for any updates in the future.

查看更多
我想做一个坏孩纸
4楼-- · 2019-01-09 02:32

Yes.There is trick with the "to" field as mentioned in below.

web URL is: https://fcm.googleapis.com/fcm/send

Content-Type: application/json

Authorization: key="YOUR_SEVER_KEY"

JSON DATA FORMAT:

{"to": "USER_FIREBASE_TOKEN",

"data": {"message": "This is a Firebase Cloud Messaging Topic Message",}

"notification": {"body": "This is firebase body",}}";
查看更多
太酷不给撩
5楼-- · 2019-01-09 02:38

You can try with topic subscriptions. It is not perfect solution but the best for me at this time.

{
  "to": "/topics/audience1_subscription"
  "data" : {
     "title" : "Sample title",
     "body" : "Sample body"
   },
 }
查看更多
登录 后发表回答