Nour Basha
Nour Basha

Reputation: 1

How to send a message to a specific user of an FCM (Firebase Cloud Messaging) token?

The issue is that FCM provides a token for each unique app for a device, so let's say two users use the same device and application, one signs out so that the other can sign in and use the app, i'm confused about how the flow should go! now the two users have the same token so both of them will receive the upcoming messages.

A similar question was asked here and here but it's still not clear for me!

Any help will be appreciated.

Upvotes: 0

Views: 3907

Answers (1)

Binil
Binil

Reputation: 454

Generate a user specific unique code to each user by yourself at the time of login.send the user specific unique code along with the push notification from server end.

Now send push notifications to all users.and when notification receives check check the user specific unique code to identify the user

When the App is killed, then by default Android will shows the 'notification data' as Notification, So the 'notification data' should be common to all users.

User specific data should be added as 'data message'.When a push notification arrives, the default Notification will be shown.And the 'data message' will get through the Intent in the launcher activity.Here you can identify the user by the user specific unique code and respond to push notification.

Upvotes: 1

Related Questions