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

前端 未结 2 2194
耶瑟儿~
耶瑟儿~ 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;
    }
    
    0 讨论(0)
  • 2020-11-29 12:22

    Even though this question is already answered and a bit old, there's a workaround. So therefore I will still add the answer for future reference. What you can do is unsubscribe the user from the topic, send the message to the topic and subscribe the user once again. Sure that is a bit more work and calls to Firebase, but then you've got what you want.

    Just a thought

    0 讨论(0)
提交回复
热议问题