How do I send notifications (push) to a specific user (from the application) from Firebase?

Asked

Viewed 831 times

0

I’m developing applications using the Ionic framework. One of the big questions I have is how do I work as remote notifications (different from local notifications, easily generated by Ionic).

Using Firebase, I was able to generate remote notifications for all devices and for specific devices, using what they call "registration_id". However, this code represents a device, not the user.

Suppose I have an application with ten users where all use the same device. My question is the following: How do I send a specific notification to one (or more than one) of these users?

I initially thought that this problem would be solved with a relational table, where it would be possible to relate the application user ID to its last registered_id, it is therefore necessary to update this table, if necessary, every login. However, I see that this solution has some flaws.

1 answer

2

There are two ways you can do this. The first is by using the groups from Firebase. The group is a set of a user’s devices. (I haven’t used this Firebase feature yet, so I don’t know if it’s easy to implement)

The second way is to create a topic for the user (e.g.: user-<ID>) and re-reference that user’s devices by adding them to the topic, or removing.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.