Push notification to all the users subscribed to the topic except login user using FCM Firebase

前端 未结 2 2196
耶瑟儿~
耶瑟儿~ 2020-11-29 11:28

Now i have a group which have more than ten thousand members and for a group i have created a topic(Notification topic) where all the users in the group subscribed to that t

2条回答
  •  既然无缘
    2020-11-29 12:07

    There is currently no parameter of any sort to exclude a specific user from receiving a message from a topic they are subscribed to. However, as a workaround, you could simply have a custom implementation on building the payload and handling the message to receive it.

    Depending on how you build your payload, you could just add a custom key-value pair that includes the user id of the one who posted the data (something like posterId or simply userId).

    Then on your client side, when handling the push notification, just check if the id is the user's or not. If it is the same user, don't show the notification, else show it. e.g.:

    if (userId == currentUserId) {
        // if user is the one that sent the message, don't show the notification
        return;
    }
    

提交回复
热议问题