GCM API key vs Sender ID

28,070

Solution 1

I've kinda figured it out on my own:

  1. API key is generated on console and is used by 3rd party server to authenticate/authorize with GCM.
  2. Sender ID is used by Android app to register a physical device with GCM to be able to receive notifications from GCM from particular 3rd party server.
  3. Registration ID is a result of registration of physical device to GCM with Sender ID.

Solution 2

It depends on how your thirds party server is going to work, but in general it works like this:

  1. The app sends one or more sender Ids which are Google Project Numbers to the GCM servers.
  2. GCM returns a registration Id, which the app uses to register with the server.
  3. The server uses the registration Id and the API key to send a message to the device via GCM.
  4. When sending the message GCM will ensure that the Google Project Number and API key match and match what was used to create the registration Id. If they do it sends the message.

Information on how the developers get this information can be found in the GCM documentation: http://developer.android.com/google/gcm/gs.html

Depending on your needs there are third party commercial sever solutions available.

Solution 3

There are two keys or IDs on which GCM process rests upon. One is registrationID that is created at Android application side and sent to the Server application where API Key already stored. Message is push to the device using a combination of registration Id and API Key.

The regisration ID is generated by GCM servers when android application makes request to them. Keeping the already created project ID (at Google dev console).

Share:
28,070
Admir Tuzović
Author by

Admir Tuzović

Currently CTO @ App Impact, software development company. Pluralsight Author. Most Valuable Professional (MVP) for Microsoft Azure platform. Former Technical Evangelist at Microsoft.

Updated on July 26, 2022

Comments

  • Admir Tuzović
    Admir Tuzović almost 2 years

    I am confused about GCM Sender ID and API key. I'm responsible for building 3rd party server that will send notifications to Android app.

    Which one do I have to store on server side? API key or Sender ID? Who is responsible for creating both, Android developer or me?

  • Vincent
    Vincent about 8 years
    Also, Project ID is same as the Sender ID
  • Ben Butterworth
    Ben Butterworth almost 3 years
    Point 2 is the answer to "What is sender ID used for?". Just adding that for SEO, it took me too long to find this answer 😂. The answer is it is used by Android devices to identify which Firebase project to register with. I wondered why the other information in google-services.json isn't enough, its because the sender ID is literally the Firebase project ID, as vincent said.