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.
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.
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.
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
Click the “Choose and configure services” button. You are taken to a section with a large “Enable Google Cloud Messaging” button. Click 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
Copy-paste that Server Key to a buffer. You will need it in a moment.
Next, click “Continue to Generate configuration files”.
On that screen, click “Download
foo.bar”. This will download a file called
google-services.json, which you will need in the next section when setting up your client application.
Now skip down to “Give us your Server Key”, where you will need the Server Key you just copy-pasted.
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
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.
Under “Google Cloud Messaging”, click the “Enable” button. The page may tell you to create credentials, as below.
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.
You will be given a new Server API key. It should look something like this:
Next, let’s upload the Server Key to the Pusher dashboard.
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!