11

I've read a lot of articles about Firebase Instance Id and registration token here, here and here.

I have some confusions about their scope and relationship between Instance Id and Token. I would like to validate that my understandings are correct or wrong.

  1. Instance Id is generated per App. Not per installed device. For example, if you have Mail app and Notes App, you will have two Instance Id on firebase.
  2. Token is generated per installed devices. For example, if you have ten users installing your app, you will have ten registration tokens.
  3. One Instance Id will have many registration tokens.
  4. Normally, we only have to keep registration tokens (not Instance Id) on our App Server to send push notifications.
Steve.NayLinAung
  • 5,086
  • 2
  • 25
  • 49

1 Answers1

11
  1. Partly correct. An InstanceID pertains to the app instance. In your example, if you have the Mail App and the Notes App, each has their own instance id, but the two are not the same, so they can't be grouped together.

    Think of the app instance as the app installation. If you have installed the app on the device, it has the app instance. If you uninstall it, it is also removed, if you re-install it, it's a new app instance.

  2. Correct. But there's also a possibility to have multiple tokens for the same device, but this only pertains to having multiple senders.

  3. Possible. See #2.

  4. Yes. The registration token is the value needed as a target for push notifications.

Community
  • 1
  • 1
AL.
  • 36,815
  • 10
  • 142
  • 281
  • Thanks for your answer. About Instance ID, if my Notes app is installed on ten different devices, will there be ten different Instance Id or only one Instance Id? – Steve.NayLinAung Jul 17 '17 at 09:15
  • 2
    Ten different IDs. When you install your app, you could actually call `FirebaseinstanceId.getId()` which would return the value for that specific *app instance*. And when you call `getToken()` (currently) it returns the token as `:` -- but the registration token is recognized as this exact whole value. – AL. Jul 17 '17 at 09:23
  • I've accepted your answer. According to the statement "If you uninstall it, it is also removed". How can our App server knows this Instance Id or Registration token has been deleted (or invalidated) on device? – Steve.NayLinAung Jul 17 '17 at 11:40
  • See my answer [here](https://stackoverflow.com/q/41552610/4625829) (Diego's answer is also good) – AL. Jul 17 '17 at 11:43
  • You are really awesome. – Steve.NayLinAung Jul 17 '17 at 11:44
  • Thank you. Good luck with your app. :) – AL. Jul 17 '17 at 11:44