Esri's Geotrigger Service is replacing Geoloqi! Learn More | FAQ

Configuring Push Notifications - Android SDK

Note: Google's C2DM service has been deprecated. Applications already using C2DM will continue to be supported, but new applications must use Google's Cloud Messaging service.

You must have a Google account set up on your device or emulator in order to register with the GCM server and receive messages.

Geoloqi push notifications are sent to Android devices using the native Google Cloud Messaging for Android (GCM) service.

For details on using GCM please read the Getting Started guide on the Android Developers website.

Create a Google API Project

The first step is to create a new Google API Project by navigating to the Google APIs Console page. If you've already created a project, navigate to Other projects > Create.

Find your project ID

Take note of your project ID, which will be used later as your GCM sender ID. You can find the project ID by examining your browser URL:

The numeric value after #project: is your project ID.

Enabling the GCM Service

  • In the main Google APIs Console page, select Services.
  • Turn the Google Cloud Messaging toggle to ON.
  • In the Terms of Service page, accept the terms.

Obtain a Google API Key

  • In the main Google APIs Console page, select API Access.
  • Click Create new Server key. Either a server key or a browser key should work. The advantage to using a server key is that it allows you to whitelist IP addresses.
  • Click Create.
  • Take note of the API key value.

Once you have both your Google project ID and your API key, you're ready for step 2.

Note: If you wish to add a whitelist of IP addresses, you'll need to add the IPs of our servers that send out notifications. Note that this list may change over time as we add more backend capacity, so you'll need to check this list periodically.

Update your Geoloqi Application with the Google API Key

Having configured your Google API project in the first step, you can now update your Geoloqi application with your Google API key. To do so, you must open your application list, find the desired application, click the "edit" icon and expand the Configure Android Push Notifications section.

From here, simply copy and paste your Google API key into the text field with the API key label and click the Update button to save your changes.

Once completed, you'll be redirected back to the Geoloqi developer site and you can move on to the next step.

Configure Your Android Manifest

Having configured GCM and linked your Google API Key with your Geoloqi application, you're ready to start configuring your Android manifest.

You can easily generate a fresh manifest with all the push notification code included by running the tools/generate-manifest command-line script included in the Geoloqi Android Sample Application.

However, if you want to manually update your existing manifest, you'll need to declare the following receiver and permissions in your AndroidManifest.xml. You must replace all instances of the text com.geoloqi.sample with your application's package name:

    <!-- Note: This custom permission name should begin with your
         application's package name! -->
        android:protectionLevel="signature" />

    <!-- These permissions are required to enable the GCM features of the SDK. -->
    <uses-permission android:name="com.geoloqi.sample.permission.C2D_MESSAGE" />
    <uses-permission android:name="" />

                <action android:name="" />
                <action android:name="" />

                <!-- This should equal your application's package name! -->
                <category android:name="com.geoloqi.sample" />

Start The Tracking Service

The final step is to ensure you provide the GCM Sender ID when starting the tracking service. How you do this depends on whether you're using the Geoloqi native SDK or the Titanium Module.

Make sure you also include a valid push_icon, otherwise push messages will not be displayed to the end-user.

Geoloqi SDK

If you're using the native Geoloqi SDK you just need to provide the GCM Sender ID in your file (in your application's assets directory).

See the file for an example configuration.

Titanium Module

If you're using the Geoloqi Titanium module you must provide the GCM Sender ID in the init method when starting the module. Leave clientSecret blank for security reasons.

// import the Geoloqi Module
var geoloqi = require('ti.geoloqi');

    clientId: "YOUR_API_KEY",
    clientSecret: "",
    pushSender: "0000000001",
    pushIcon: "push_icon",
    trackingProfile: "PASSIVE"
    onSuccess: function() {
        // ...
    onFailure: function() {
        // ...

Optional: Disable Automatic Display of Notifications

You can optionally disable the SDK handling push messages. If you do this, the location service will still receive push messages, but will not automatically create a status bar notification. This will allow you to manually handle incoming push messages.

To do this, run LQSharedPreferences.disablePushNotificationHandling() after setting the API Key.

To manually handle push messages you can should:

  • Subclass LQBroadcastReceiver and implement the abstract method LQBroadcastReceiver.onPushMessageReceived(android.content.Context, android.os.Bundle).
  • Register your broadcast receiver to Listen for the LQBroadcastReceiver.ACTIONPUSHMESSAGE_RECEIVED broadcast intent.