Generating Your GCM Sender ID and Server Key for Chrome Push
Firebase, Google's cloud-based tool suite, can help add flexibility and user friendliness to apps. This guide walks you through setting up push notifications.
Join the DZone community and get the full member experience.Join For Free
Google Cloud Messaging (GCM) is a free service that enables developers to send messages between servers and client apps. This includes downstream messages from servers to client apps and upstream messages from client apps to servers. Starting in May, Google Cloud Messaging Platform is being replaced by Firebase Cloud Messaging.
Before 2014, GCM could only be used to send downstream messages (cloud-to-device) via HTTP. A GCM message sent with the HTTP API can be sent up to 1000 users, requiring multiple messages for large numbers of users. The new API offers an alternate method using XMPP, the GCM Cloud Connection Server. The CCS allows for a constant connection to Google’s GCM servers and messages to be sent at the max wire speed. Google throttles this speed to be 4,000 messages per second at maximum, per connection; with a 10-connection maximum. When using all 10 connections you can send 40,000 messages per second. A key difference is that messages sent using Google’s CCS is one message per device, rather than messages with multiple recipients.
Some key features of this Google Cloud Messaging Server are:
- Versatile messaging target.
- Downstream Messaging.
- Upstream Messaging.
Watch this video to understand more about GCM:
What Is Firebase Cloud Messaging?
Firebase Cloud Messaging (FCM): Firebase is the new and evolved version of GCM. Firebase comes with lot of new features along with the obvious reliability and scalable GCM infrastructure. Read more about Firebase here.
How Do I Use a Server Key?
Server Key: This is the key saved on the app server that provides the app server authorized access to Google services. As a recommended practice, you should never include the API key anywhere in your client code.
GCM Sender ID vs. FCM Sender ID?
Google Cloud Messaging (GCM) Sender ID: A unique numerical value that is created when you configure your project in the Google Developer Console/ Google Cloud Console. The Project Number is the GCM Sender ID, and this is used in the registration process to identify an app server that is permitted to send messages to the client app.
Firebase Cloud Messaging/FCM Sender ID: This is the equivalent of the Google Cloud Messaging (GCM) Sender ID. It's accessible under the Firebase > Project > Settings > Cloud Messaging tab.
What Are Chrome Push Notifications?
Chrome web push notifications are clickable messages that are sent to the Chrome browser on your user’s device. These modifications can only be sent to your subscribed users. In order to get these notifications, the subscribers do not have to be on your website. Your users can easily subscribe to these notifications on mobile, desktop, and tablet.
Read here more about web push notifications and all the other browsers that it supports.
Steps to Generate Your Google Cloud Messaging (GCM) Sender ID
1. Sign into your Google Cloud Platform Account on https://console.developers.google.com
Once in the dashboard, go to Create a project from the drop down menu.
Generating GCM Sender ID – Step 1- Project Creation
2. Enter the Project name and click on Create
GCM Project Creation
3. Once the project is created, go to Overview and search for Google Cloud Messaging.
Select Google Cloud Messaging.
Enabling Google Cloud Messaging API
Google Cloud Messaging API
4. Click on Enable and move to the next step to create credentials.
Confirmation of Activation of GCM API
GCM API Credentials
5. Under the Credentials section, select Create credentials and choose API key from the list.
GCM Sender ID and API Creation
6. From the reflected options select Server key to create a new key.
New Key Generation
7. Enter the server key name and move to the next step by clicking on Create.
Name Server Key
8. This is what your API key will look like.
Server Key Generated
9. To get your GCM Sender ID – select the option to Manage all projects from the drop down section.
Manage Projects in GCM
10. Select your project from the list of all projects.
GCM Sender ID
11. Go to the Settings section to view your Project number, which is your GCM Sender ID.
Project Number is Sender ID
GCM is now FCM!
If you have followed this tutorial about GCM, we strongly recommend you migrate to Firebase cloud messaging today itself. Read here to understand what’s changed and get started by generating your server key using these easy steps.
Published at DZone with permission of Ruchika Sharma. See the original article here.
Opinions expressed by DZone contributors are their own.