如何将Firebase推送通知发送到Android的特定用户组 [英] How to send firebase push notification to specific group of user for android

查看:367
本文介绍了如何将Firebase推送通知发送到Android的特定用户组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Firebase创建了推送通知服务,可以将通知发送给具有FCM ID的所有或单个用户,但是我不知道如何发送给特定用户.

I Have created push notification service using Firebase and I can send notification to either all or single user having FCM id, but I have no idea how to send to specific user.

还没有创建用于处理推送通知处理的服务器面板.如果有任何建议可以帮助您解决更多问题.

Also server panel is not created for handling push notification handling If any suggestion for that is there will help more.

推荐答案

Firebase Cloud Messaging(FCM)主题消息传递可让您向选择加入特定主题的多个设备发送消息.基于发布/订阅模型,主题消息支持每个应用程序的无限制订阅,即您的组被附加到新闻组,体育组等特定主题.

Firebase Cloud Messaging (FCM) topic messaging allows you to send a message to multiple devices that have opted in to a particular topic. Based on the publish/subscribe model, topic messaging supports unlimited subscriptions for each app i.e your group is attached to specific topic like news group,sports group etc.

FirebaseMessaging.getInstance().subscribeToTopic("news");

退订unsubscribeFromTopic("news")

从服务器端,您需要设置特定主题,即像这样的一组用户:

From Server side you need to set up for specif topic i.e a group of user like this:

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

{
  "to": "/topics/news",
  "data": {
    "message": "This is a Firebase Cloud Messaging Topic Message!",
   }
}

"/topics/news"这将向订阅新闻主题的人群发送通知

"/topics/news" This will send notification to group of people who have subsribe the news topic

这篇关于如何将Firebase推送通知发送到Android的特定用户组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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