What is the best way to generate Push notification using Firebase?

3

I have the following problem:

I have a system where it is possible to record a series of tasks to be performed by a team or person. What I need is that whenever a request is terminated by a user, everyone else receives a notification saying that it has completed.

My doubts are:

a) Assuming that users can enter or exit solver groups, which would be most recommended. Push Push to: Topics, Groups or single devices?

b) How to prevent Push from being generated after the user logs into the app?

Solving groups would have a model similar to What's app groups. If the user leaves the group, it is no longer notified.

    
asked by anonymous 17.05.2018 / 02:05

1 answer

0

a) Short answer: Topics .

Long answer:

Single devices would require you to create your own logic for the user to enter and exit the groups. You would have to save each user's token in a database (which may be more expensive, depending on the boundaries of your database).

Groups - although the name is suggestive,

Topics - Just like in groups, you do not have to manage the tokens for each device that is part of a "group" (other than single devices) because Firebase does that for you. And the SDK is very easy to use. For a user to join a group, you would:

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

And for him to leave the group:

FirebaseMessaging.getInstance().unsubscribeFromTopic("idGroup");

b) If you are using Firebase Auth, when logging off it will no longer have access to push notifications. If you're not using Auth, try calling deleteInstanceId() during log off.

    
17.05.2018 / 23:41