Quickstart to use Altair SmartWorks & Google Cloud Messaging (Android)

0. Introduction

This easy tutorial helps you to send PUSH Notifications to your Android devices using Google Cloud Messaging.
In this project you will learn how to:

  • Connect Altair SmartWorks with Google Cloud Messaging to send PUSH notification using a listener
  • Receive notification in your Android devices.

TOP

1. Steps to Connect with Google Cloud Messaging

Before starting, you need to take some previous steps.

Get the Quickstart project

You need download the Quickstart project to install in your Android devices and receive the notifications.

You can download from this link:

Quickstart project

Extract the zip and place it in your Android Studio projects folder.

Register the project and get the configuration file

You need to provide some additional information to get a configuration file and register your project.

Get Configuration File

  • GCM Register project
  • GCM Enable Services
  • GCM Generate Configuration File

After you complete the registration, download the google-services.json file to add to your project.

Also, copy the Server API Key. Before running the app, you will need to add this in the GcmSender.java file of your project.

  • GCM Register project

Add the configuration file yo your project

Copy the google-services.json file into the app directory of your Android Studio project.

  • GCM Select Quickstart project
  • GCM Select App folder
  • GCM Copy google-services.json file

Run the project in Android Studio

Now you can build the project and run it from Android Studio.

First, add the Server API Key in the GcmSender.java file.

  • GCM Copy Server API Key

Click the run button and select a virtual device or connect your Android device to the computer to run the application in the device.

  • GCM Run APP

When the application loads on your device, you will be able to receive notifications from Google Cloud Messaging in your device.

  • GCM APP working

TOP

2. Send data from Altair SmartWorks to Google Cloud Messaging using a listener

We have enhanced the listener creation process with our Flow Tool.

Now we will build a listener in Altair SmartWorks to send data to Google Cloud Messaging based on this Alert System Tutorial to receive a notification when the light is turned ON or OFF.

In the Flow editor we'll only need to drag & drop a "function" node and add our custom code since this tutorial is not intended to explain the details of the Flow Tool. For a deeper vision of the tool please read its documentation or our "How to create a listener" tutorial.

  • Flow designer: function node

After saving it, your listener will look something like this.

  • Resulting listener
  • Stream list of sent data
  • Notifications received

TOP