1

I have read documentation, and watched videos, but this is something that is still confusing me.

I used PRODUCT_ID in my android app and send it to Google Cloud Messaging (GCM), so that it returns me TOKENID, that i send to the server.

  1. So Is ProductID is just a random unique number, that we send to GCM?
  2. GCM still sends me TOKENID, When i write Random Numbers as PRODUCTID, so will it work if send this Token to my server.
  3. Does GCM use the generated registrationID to communicate between server and Device or it checks PRODUCT ID on each request.
Taha Kirmani
  • 1,274
  • 6
  • 26
  • 55
  • So does it communicate on the basis of `TokenID`, or i need to put the same `11-digit Product ID` that `GCM` provided, or i can write any `11 Digit ` unique number – Taha Kirmani Jun 22 '16 at 07:20
  • 1
    No, you have to use GCM provided product-id, not the id created by you. That is being used to identify you server app. – Pankaj Kumar Jun 22 '16 at 07:24
  • Together with below answers, hope [my answer here](http://stackoverflow.com/questions/33489862/google-gcm-token-vs-registration-id/33490670#33490670) also helps you – BNK Jun 22 '16 at 07:42
  • Thanks @BNK, I have asked a question on your answer, kindly check it – Taha Kirmani Jun 22 '16 at 07:47

2 Answers2

1

Hope the following diagram helps you to understand better

enter image description here

You can find more explanation over here or in the second part of the tutorial over here

Project Sender ID can be found once you create the project in developer console. This id needs to send in initial registration request send to GCM. Check the folowing image
enter image description here

Sreehari
  • 5,621
  • 2
  • 25
  • 59
  • Thanks, this made it quite clear.. Still 1 question, Will it work the same way If i use some `random number` as `Sender ID`, and generate Token from this, So Will `GCM` still be able to send me Notifications. – Taha Kirmani Jun 22 '16 at 07:30
  • @TahaKirmani Ive updated the answer with another image, You have to send that ID to server and not any random number – Sreehari Jun 22 '16 at 09:10
1

You can not use random number generated by you for sender-id. That must be the one which you got from GCM.


To register with GCM:

  1. The client app obtains a registration token using the Instance ID API. The call to this API must have the authorized entity set to your app server's sender ID, and the scope set to the appropriate value for GCM (depending on your platform). Refer to the API reference for full detail on this API.
  2. The client app passes the registration token to the app server.
  3. The app server saves the registration token and acknowledges to the client app that the process completed successfully.

Read more about Registering Client Apps

Pankaj Kumar
  • 81,967
  • 29
  • 167
  • 186