Enabling the Kii Push Notification Feature with GCM
Follow the steps in this topic to use GCM push notification in the mobile app of Hello Thing-IF.
We explain how you can create a project with the "Get a configuration file" feature provided in the GCM documentation site (you can alternatively create a project on the Google Developers Console).
Once the configuration is done, you can download the JSON file. We will integrate this file into the Android project so that the mobile app can use the configuration.
Note: You need to be registered as a Google Play developer in order to walk through this tutorial.
Open the tutorial page in the GCM documentation site.
Scroll down to the section "2. Get a configuration file" and click GET A CONFIGURATION FILE.
You will be directed to the Google Developers page.
Here, you can create a new application by entering the following information and clicking Choose and configure services.
- App name
Hello ThingIF. The Google Developers Console will use this to identify the project.
- Android package name
com.kii.sample.hellothingifthat is the package name of the Android app.
- Share your Google Mobile Developer Services data...
- Configure if you want to provide the application usage data to Google. Select at your will.
- Your country/region
- Set the location where the application developer resides.
You will be now directed to the service selection screen.
Selecting Cloud Messaging will bring up the next screen. Click ENABLE GOOGLE CLOUD MESSAGING.
The section will turn green indicating that the feature is now enabled. You will find the Server API Key and the Sender ID by scrolling down a bit.
We will use the Server API Key and the Sender ID later. For now, make a note of those values.
- Server API Key: We will set the value in the developer portal. In the developer portal, the value is called GCM Key.
- Sender ID: This value will be auto-configured with the JSON file and you do not need to configure it manually. Still, you can check the value in the debug mode.
Now, scroll down and click Generate configuration files.
The button for downloading the JSON file will show up. Click Generate configuration files and save the JSON file on the local PC.
Copy the file that you have just downloaded to the app directory of the Android Studio project.
This completes the configuration on the GCM side. You can now close the screen.
If you want to check the Sender API Key and Sender ID again later, open the Google Developers Console.
Select the target project from the list and check following values.
- Server API Key: Check the Key in the Server key on the Credential screen.
- Sender ID: Check the Project number shown when you open the project.
To learn more about the Google Developers Console in general, please consult other technical web pages.
Now you will register the GCM API key on the Kii Cloud developer portal.
Open the Kii Cloud developer portal (http://developer.kii.com) and configure your application.
On the application console, click the Edit icon.
Now Select PUSH NOTIFICATIONS. On the push notification configuration screen, set your GCM API key. The GCM API key is the value shown like this as Server API Key.
When you are done, press the SAVE button.
You can download the Google Play services library (Google Repository) on Android Studio.
Launch SDK Manager from the toolbar at the top of Android Studio.
The SDK configuration screen will show up. Open the SDK Tools tab, select Google Repository from the list, and click the Apply button. The library will be downloaded and installed in the build environment.
If the library is already installed, just close the screen.
- See Android (GCM) Push Notification Tutorial to learn how to set up GCM in a new project.