Push Notifications: Setting up GCM

Our Push Notifications system is currently in beta. This means you may experience errors, and the APIs may change. We would love to hear your feedback, so please get in touch!

Pusher can use GCM to deliver push notifications to your user’s Android applications on your behalf. When we deliver push notifications over GCM, we use your GCM credentials. You provide us with your credentials in the form of a Server Key. This page guides you through the process of getting a Server Key and providing it to Pusher to send Android push notifications.

You may already have an Android app which you would like to configure. If you just want to set up an app using WebSockets, see our Android Quick Start guide.

Getting a Server Key

Note: Terminology differs. The Google Developers Console, hosted at https://console.developers.google.com/, also identifies itself as the Google APIs dashboard. Google Projects are also referred to in places as “Apps”. You will also see the term “Sender ID”, which is the same as the Project Number which identifies your Google Project.

When Pusher sends a push notification through GCM, it authenticates using a Server Key provided by you. This section guides you through getting a Server Key from Google.

Each Server Key is associated with a Google Project. To obtain a Server Key, you require a Google Project. To send push notifications with this Server Key, Cloud Messaging must be enabled for that Google Project.

Our guide depends on whether you already have a Google Project you wish to use. If you do not yet have a Google Project, follow the steps below using the Google Services Wizard. If you do have a Google Project, skip to using the Google Developers Console to create a Server Key for that project. If you’re not sure whether you have a Google Project, visit the Identity and Access Management section of the Google Developers Console, which will list the Google Projects you have created.

If you don’t have a Google Project: use the Google Services Wizard

This section will guide you through creating a new Google Project and obtaining a Server Key for it. For this, we will use the Google Services Wizard to create a new Google Project for GCM.

screenshot of wizard, with app name Your App and Android package name foo.bar, with cursor over 'Choose and configure services'

Visit the wizard. You are asked for an “App name” and an “Android package name”. The “App name” is the name of your Google Project. The “Android package name” is required, but we do not use it here - just enter foo.bar.

Click the “Choose and configure services” button. You are taken to a section with a large “Enable Google Cloud Messaging” button. Click it.

screenshot of wizard, with button 'Enable Google Cloud Messaging', with cursor over it

You have now created a new Google Project with one Server Key. You are presented with a “Server API Key” and a “Sender ID”. The “Server API Key” is the Server Key which Pusher requires, and it will look a bit like AIzaSyCXm5HCjI8agRwzZfL4H-UYQMRqrVrq3Dw. The “Sender ID” is your Google Project’s Project Number, and it will look a bit like 513326455382.

screenshot of wizard, with new Google Project details: Server API Key and Sender ID

Next, let’s upload the Server Key to the Pusher dashboard.

If you already have a Google Project: use the Google APIs dashboard

FCM (Firebase Cloud Messaging) is a different service to GCM. Pusher uses GCM, so ensure you’re following these steps at developers.google.com, and not at firebase.google.com.

You should already have a Google Project in order to follow this section. If not, follow the section above, or create a Google Project via the Identity and Access Management (IAM) section of the Google Developers Console.

Visit the Google Cloud Messaging section of the Google Developers Console. Ensure you have your Google Project selected in the top right.

screenshot of Google Cloud Messaging section of Google Developer Console, with Google Project Your Existing App in the top right, with cursor over Enable button

Under “Google Cloud Messaging”, click the “Enable” button. The page may tell you to create credentials, as below.

screenshot of Google Cloud Messaging section of Google Developer Console, with Google Project Your Existing App in the top right, with GCM enabled, with alert telling us to create credentials

To create credentials, visit this form to create a new Server Key using the Google Developers Console. Complete the form to create a new Server Key. Under “Accept requests from these server IP addresses”, leave the field blank.

screenshot of creating a Server Key in Google Developer Console, with Google Project Your Existing App in the top right

You will be given a new Server API key. It should look something like this: AIzbSyC3Gep7YeuYANR5qLJad85hLf2zNY6vQXZ.

screenshot of new Server Key in Google Developer Console

Next, let’s upload the Server Key to the Pusher dashboard.

Give us your Server Key

You should have a Pusher app which you want to use push notifications with. If not, create a new Pusher app.

Visit dashboard.pusher.com and sign in with your Pusher account.

In the dashboard for your Pusher app, go to the Push Notifications tab.

On the Push Notifications tab, click the “Configure GCM” tab.

In the section “GCM API Key”, paste the Server Key you obtained earlier, and click “Save”.

You’re done! Next, let’s set up your Android app to receive some push notifications!

Further reading

Google’s GCM Android quickstart

Have you tried using the search to find what you’re after? If you still have a question then get in touch with us and let us help you out.