In previous article I have explained complete process flow of google cloud messaging. After understanding this process and starting developing application we have create a project on google console to get few parameters to use in the application.
These parameters are:
- Project Number: This will be used as Sender Id
- API Key: This will used as API Key to authenticate our request on GCM server
- Enable Google Cloud Messaging API for Android
To sending notification from server to your android device we have do following steps before doing any coding:
- Go to Google developer console: Go to https://console.developers.google.com and login with you google account.
- Create a project: Select Create a project option from option on top right of the screen (See screenshot below).
Enter your project name in pop
Now click create. This will create the project and redirect you o the project page. If you are not automatically redirect to the project page you can select from same link where we chose create a project option.
- Generate credentials: After creating project and opening project dashboard first thing we will use is project number. This project number will be used as sender id for sending notification. After that we need to activate the Cloud Messaging API, for this
open site menu and select API Manager -> Overview -> Cloud Messaging for Android
Now you will see Enable API button on top of this tab so just click on it and wait for the operation to get completed. after enabling messaging API we can use this project for Google Cloud Messaging.
Now last thing we need to do is to get API Key which is mandatory to use any API. Click on Credential in left sidebar -> click Add credentials -> select API key. A pop will open which will show 4 buttons we have to use server as we will use this API key on our server to send messaged to GCM server. It will ask you a key name and when you click create a popup will open containing your API Key. We will use this API key to send messages from server to GCM Server.
- Create project on google cloud console
- Get project number to use as sender id for GCM messages
- Enabling Cloud Messaging API for Android
- Generating API key to authenticate your request on GCM server
- Generating registration id for android application
- Sending notification from app server to GCM
- Get messages on mobile app and display on notification bar