Is Fcm (Firebase Cloud Messaging) Token for One Device or for One Account

Firebase cloud messaging multiple devices and a single account

Firebase Cloud Messaging only knows about app instances, a single app installed on a single device.

If your app associated that with users, the logic of how to do so is application specific. If you want to alert the user on all their devices, you'll want to store multiple tokens per user. If you want to only alert the user on their active or most recently active device, you'll only want to store a single token per user. All these scenarios are possible, but you'll have to implement as part of your application logic.

Also see:

  • When to register an FCM token for a user
  • How to handle multiple Firebase FCM tokens per user?
  • Receiving the same token for different users when using firebase messaging
  • Is FCM (firebase cloud messaging) Token for one device or for one account?

Managing Firebase Cloud Messaging Tokens with Multiple Users

Yes, that is correct. An FCM token identifies an installation of a specific app on a specific device, nothing more and nothin less. It has no inherent relation to a user, so if you need such a relation, you will have to link them together yourself.

Keep in mind that just like multiple users can use a single device, a single user can also use multiple devices. In my experience that is in fact the more common scenario of the two.


Locally checking the target user of the notification against the actual current user is an interesting concept that could definitely help prevent showing the data to the wrong user.

In general though, you can also clear the token when the user signs out of your app (or a new user signs in). This is (as far as I can tell) the most common way of dealing with this scenario (see 1, 2, and more from this).

Is the firebase cloud messaging registration token per app or per device?

A registration token is associated with an app instance -- an app's installation (also mentioned it here). Since it's two different apps, it should generate different tokens.

With that said, I would suggest making different projects per app in your developer account.

send cloud message (FCM) multiple devices single user

You need to change your DB and add ability to save all device tokens from one user. Then you need to call this Firebase api https://fcm.googleapis.com/fcm/send as many times as the tokens user have. Here the official documentation.

https://firebase.google.com/docs/cloud-messaging/http-server-ref

To update device specific token when it is changed on client side, you also have to bound that token with the deviceID, so to have that you need to pass the DeviceId to the server when passing the Firebase token. As deviceID can serve Android unique deviceID, or the id that provides Firebase in client side FirebaseInstanceId.getInstance().id. And here how to get Android deviceID

Is there a unique Android device ID?

If you use access_token for login the user, as another alternative, you can bound firebase token with user access_token, as it is unique for any device the user logged in.

What's the difference : FCM Token / APNs Token / Registration Token / Device Token

There are two definitives here:

  • APNS Token is the Apple Push Notification Service token. It is a token (think of it like a password) that authenticates your app and device onto the Apple Push service and allows for communications to be sent.
  • FCM Token is the Firebase Cloud Messaging token. This is googles version of the APNS Token however works for both iOS and Android (Google do proxying on their end when sending a push notification to iOS devices).

When you refer to a registration token or a device token it really does depend on the context you use the phrases. They are often used interchangeably and neither are really "official" terms. For the most part, both terms refer to your APNS/FCM token, however device token has historically been used for other things like unique device identifiers.

Are Firebase Cloud Messaging (FCM) tokens unique?

When I search for Are Google Cloud Messaging tokens unique, the first result is this page from the documentation, which says:

To verify that they can send and receive messages, client apps must register with GCM. In this process, the client obtains a unique registration token...

Firebase Cloud Messaging Instance ID Tokens uniquely identify an instance of an app. They are globally unique.

Whether you should mark the column in your database as unique depends on your usage of that column. As yourself questions like: what bad thing will happen if a token is present twice in this table? Will marking the column unique prevent the bad thing from happening?



Related Topics



Leave a reply



Submit