58

I am developing an Android app and I'd like to start testing out push notifications. From a code perspective, I'm all set. My current challenge is that I simply do not know how to get a Google Cloud Messaging API key from Google.

There are loads and loads of tutorials and videos online showing how this can be done in about 10 seconds but Google has recently updated it's developer center and none of the tutorials seem to apply any more. The current process seems very cumbersome and not at all similar to what I've seen online.

I realize that this barely passes as a programming question (if at all) but there is no way that I'm going to even begin to be able to develop anything without an API key from Google.

Is someone able to point me in the right direction?

1

5 Answers 5

76

CommonsWare was right about three years ago (2013). This is a revision to his answer.

Note: Even if you have already enabled any services and have API keys this will still work.

  1. Log in to Google Services with your google account. (This is not the same as the Google Console)

  2. Click on Pick a Platform

  3. Click on Enable services for Android

  4. Fill out the app name and package name

  5. Select Cloud Messaging. (Or any other service you want. You can come back to this later and add more)

  6. Click on Generate Configuration Files

  7. Boom. Right there on top in the Cloud Messaging card under Server API key

  8. Also, you will want to download the google-services.json file and copy it to the app/ or mobile/ module directory in your Android project

6
  • 1
    Hopefully enough upvotes will get this answer to the top. It is possible to generate an API key through the developer console however, and I left a message for CommonsWare letting him (them) know that.
    – akousmata
    Jul 13, 2015 at 15:36
  • The only option I get in 'App Name' is 'Google Play Android Developer'. I want to reference my apps in the play store but they don't seem to be showing up. Is there some difference between the "Google Play Developer Console" and the "Google Developers Console" that I'm not aware of? If so, how do I link them? If they are already linked, then what name do I use for #4 in reference to the app (App store name is no good because my app has an '&' and that character isn't allowed in #4. Oct 6, 2015 at 9:06
  • Or maybe it's the package name that really matters and the app name is a just an identifier? Oct 6, 2015 at 9:16
  • 1
    @kraftydevil Yes your app name is just an identifier for you. Your package name wont be there until you manually type it in. Oct 11, 2015 at 21:03
  • @RyanH. you mean 2016? Oct 13, 2016 at 21:27
49

but Google has recently updated it's developer center and none of the tutorials seem to apply any more

:: sigh ::

That's yet more work for my next book update...

The current process seems very cumbersome and not at all similar to what I've seen online.

Bearing in mind that I am already set up with keys, and therefore may be seeing somewhat different stuff than would somebody with no keys:

Step #1: Log into https://cloud.google.com/console with your Google account

Step #2: In the navigation on the left, go into "APIs & auth > APIs"

Step #3: Find "Google Cloud Messaging for Android" and click the "OFF" button next to it (note: this might involve then agreeing to additional terms of service)

Step #4: In the navigation on the left, go into "APIs & auth > Registered apps"

Step #5: Wait a really long time, apparently.

Step #6: Click the red REGISTER APP button.

Step #7: Give the app a name and choose Web Application, then click Register

Step #8: Click the "Server Key" section for your server key

8
  • Ugh...I'm an idiot...ish. When previously trying to register my app, I was choosing "Android" which was requiring me to enter additional info that I did not have and was not going to have for a while. Using "Website" to register the app made everything super easy...assuming that the API key generated works. Nov 8, 2013 at 19:27
  • 3
    I would never guess to choose WebApplication instead of Android . I was struggling my head trying to use that API Key generated when I chose Android for platform.....even passed my phone number :X
    – AlexAndro
    Nov 11, 2013 at 20:20
  • go into "APIs & auth > Registered apps" Nope. Not there. Apr 13, 2015 at 16:50
  • @nVentimiglia: This answer is ~18 months old, and Google redesigns the site from time to time. As I avoid using Play Services in general, I cannot tell you what the current site structure is. Apr 13, 2015 at 16:53
  • 4
    @CommonsWare ::sigh:: is right, it's updated again and this post is old. Starting at step #2, instead of APIs go to Credentials -> create new key -> click Server Key -> enter IP ranges you want it restricted to (or leave blank) -> click Create, done.
    – akousmata
    Jul 13, 2015 at 15:35
5

Google has updated their api console recently to Google Cloud Console. In short terms , you need to create an Android application and pick Accessing APIs via a web server. this service has a detailed guide for that

4
  • 5
    seems some of us aren't getting shown a "Registered Apps" submenu option.
    – jrg
    Dec 19, 2013 at 13:42
  • It might be a permission issue - do you have admin permissions on that Google account?
    – Orr
    Dec 20, 2013 at 14:51
  • 1
    Turns out they've renamed/moved options about (at least, in the views I get) but not updated their documentation to reflect that. Go to APIs & Auth > Credentials. If you're simply wanting your web app to send GCMs then use the API key value from 'Key for server applications' - you'll need to add your IP addresses into the list.
    – jrg
    Jan 2, 2014 at 12:42
  • They updated their documentation now... from my understanding, you need a Browser Key and don't put anything in the ip list
    – Orr
    Jan 13, 2014 at 11:00
4

The easiest way to configure GCM API key and Sender ID, is to Google login with your account and continue the Wizard : https://developers.google.com/mobile/add :)

1
  • 1
    This is the way to do it currently!
    – Marcie
    Dec 9, 2016 at 1:17
1

To get FCM (Firebase cloud messaging) key for a web app

  1. login into Firebase
  2. Create a new app by clicking the big 'Add Project' button

    Wait a few seconds and watch the circle chase its tail

  3. Click "Add Firebase to your web app "

  4. Copy the api key

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.