Quickstart to use Altair SmartCore & 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 SmartCore 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 SmartCore to Google Cloud Messaging using a listener

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

If expression

Then expression

Else expression

  • Listener to send data to GCM
  • Stream list of sent data
  • Receive notifications

TOP