NOTICE! GCM is deprecated. Please use FCM for sending push notifications to your Android or iOS apps.
To be able to send GCM from your server to your app, you need a GCM SenderID and a server API key. In this tutorial you will see how to generate these two Strings for your Android app. After you finished the Android part, you will also learn how to do a similar thing on the iOS side but please notice that you need to complete the Android part first (even if you are building for iOS only). The reason is that google API console does not yet have all the settings in one place which may make the steps look very confusing. I can guess that Google will soon move the steps all into its API console but as right now, they are separated. When they fix their console, I will also update this tutorial. Until then, prepare yourself for 15 minutes of weird steps! When I say weird steps, I totally target the iOS side. You will understand why I’m saying it’s weird soon
So, in brief, our objective is to create a server API Key to be used on our server PHP code so we can connect to Google GCM servers and we also need two SenderID Strings. One to be used for the Android side and one to be used for the iOS side. Here we will create them for the Android side. If you are looking for the iOS steps, read here.
Now go to the “Home” page from the left panel and there you will see the SenderID for the Android side of your gcm.
As shown in the screenshot, your senderID is a number like “922435504281”. This is the number you will later use in your AS3 app while initializing the GCM extension.
2) Enable GCM for Android
Now that you have your project created, you need to enable gcm for Android. To do that, go to APIs page from the left menu and as you can see there are some APIs already enabled by default but we need to add GCM manually ourselves.
Simply search for “cloud messaging” in the search box and click on “Google cloud messaging for Android”
And then click to enable it.
Now if you go back to the APIs page, you will see that GCM for Android is now enabled for your project.
2) Generate the server API key
Go to “Credentials” page from the left menu and click on “Add Credentials” to create a new “API key”.
A box will open which you should select the “Server key”.
On the next page you should enter a name for this new server key. It really doesn’t matter what name you specify. So just hit the “Create” button.
A popup will open showing your server API key. This will be the key you will need on your server for sending GCM messages. This will work for both Android and iOS apps if you are adding the iOS setup over the same project. Don’t worry; I will explain it later in the iOS side.
Adobe Air GCM tutorial get senderID and server API key for Android
How to setup GCM SenderID for Android side
To be able to send GCM from your server to your app, you need a GCM SenderID and a server API key. In this tutorial you will see how to generate these two Strings for your Android app. After you finished the Android part, you will also learn how to do a similar thing on the iOS side but please notice that you need to complete the Android part first (even if you are building for iOS only). The reason is that google API console does not yet have all the settings in one place which may make the steps look very confusing. I can guess that Google will soon move the steps all into its API console but as right now, they are separated. When they fix their console, I will also update this tutorial. Until then, prepare yourself for 15 minutes of weird steps! When I say weird steps, I totally target the iOS side. You will understand why I’m saying it’s weird soon
So, in brief, our objective is to create a server API Key to be used on our server PHP code so we can connect to Google GCM servers and we also need two SenderID Strings. One to be used for the Android side and one to be used for the iOS side. Here we will create them for the Android side. If you are looking for the iOS steps, read here.
1) Create a new project in Google API console
Go to https://console.developers.google.com/ and click on “Create Project” button to add a new project.
Now go to the “Home” page from the left panel and there you will see the SenderID for the Android side of your gcm.
As shown in the screenshot, your senderID is a number like “922435504281”. This is the number you will later use in your AS3 app while initializing the GCM extension.
2) Enable GCM for Android
Now that you have your project created, you need to enable gcm for Android. To do that, go to APIs page from the left menu and as you can see there are some APIs already enabled by default but we need to add GCM manually ourselves.
Simply search for “cloud messaging” in the search box and click on “Google cloud messaging for Android”
And then click to enable it.
Now if you go back to the APIs page, you will see that GCM for Android is now enabled for your project.
2) Generate the server API key
Go to “Credentials” page from the left menu and click on “Add Credentials” to create a new “API key”.
A box will open which you should select the “Server key”.
On the next page you should enter a name for this new server key. It really doesn’t matter what name you specify. So just hit the “Create” button.
A popup will open showing your server API key. This will be the key you will need on your server for sending GCM messages. This will work for both Android and iOS apps if you are adding the iOS setup over the same project. Don’t worry; I will explain it later in the iOS side.
Google has recently updated the design of their API console page. here are some other new screenshots which you may find helpful also: https://github.com/myflashlab/GCM-ANE/issues/2#issuecomment-173929829
Share this:
Related