0

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.

Community
  • 1
  • 1
Nour Basha
  • 1
  • 2
  • 2
  • Possible duplicate of [How to send notification to specific users with FCM?](http://stackoverflow.com/questions/37700995/how-to-send-notification-to-specific-users-with-fcm) – Akshay Bhat 'AB' Dec 09 '16 at 10:51
  • edited my post with the link but it's still not helpful for me, thanks anyway. – Nour Basha Dec 09 '16 at 11:06

1 Answers1

1

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.

Binil
  • 454
  • 3
  • 11
  • This approach is not efficient for both the server and all clients, as for each message the server must send it to all users, and, moreover, each user needs to compute if it is the right recipient. The right approach is selecting the recipient (FCM token) only via server-side and send the message only to the corresponding user. – nibbana Jan 23 '19 at 17:04