Search code examples
firebasereact-nativepush-notificationfirebase-cloud-messagingreact-native-firebase

Does firebase cloud messaging allow targeting of push notifications to a specific device/user etc


I am trying out firebase cloud messaging (React-native-firebase) and it seems that I am only able to push notifications to all android/ios users, not specific users. Is there a way to target a specific user. Like if a user invites another user only send notification to that one specific user?


Solution

  • The flow can be this one:

    • User allow notifications on their device(s)
    • Grab the generated token and store it in the user document inside a tokens array.
    • (If the same user connects to your app in another device, add the new token in the tokens array)
    • If you want to target a specific user, get his UID and send a notification to their devices.
    • You can also subscribe a user to a topic and send a notification to users subscribed to that topic.