To enable Google Cloud Messaging (GCM) in Intercom you first need to create a project on the Google Developers Console, set up your application to generate an instance id and add the server key to your Intercom API keys.

Step 1. Create Google Developers Console project

If you already have a Google project with a GCM server API Key then you can skip to the next step. Otherwise go to https://developers.google.com/mobile/add and create a new project following these steps.

Name the project and give it the package name of your Android app.

Make sure to enable Google Cloud Messaging.

Copy your Server API Key for the next step.

Download the google-services.json for Step 3 integrating into the client app.

Step 2. Add GCM API key to Intercom for Android settings

Open the Android Integrations page in your Intercom app's settings. Find the "Enable GCM" section. Here you'll be able to paste and save your GCM key.

Step 3. Setup client to receive push

To set up your client to receive GCM follow googles steps documented here (https://developers.google.com/cloud-messaging/android/client). The explains how to generate a configuration file and the necessary changes to your client’s code and androidmanifest.xml

Step 4. Register for Intercom GCM

Once you have an instance id you will need to send this to Intercom. Do this by calling:

Intercom.client().setupGCM(instanceId, R.drawable.ic_launcher);

This takes the instance ID and an image resource which allows us to draw your company or app logo on the cloud messages. We recommend following the material design guidelines for producing this icon (http://developer.android.com/design/patterns/notifications.html).

Step 5. Open Intercom conversations from GCM

To allow a cloud message to open the app and jump straight to an Intercom message we need to get the intent data sent to us. In your apps launch activity (the first activity it will go to) add the following. You should call this method early in the Activity life-cycle such as onCreate.

Intercom.client().openGCMMessage(getIntent());

If you wish to create a custom back stack for this notification you can pass a TaskStackBuilder to the same method:

openGCMMessage(Intent intent, TaskStackBuilder stackBuilder);

Step 6. Disable GCM on log out

To stop users from receiving messages when they have logged out of the app make sure Intercom.client().reset() is called.

Step 7. (optional) Prevent drawing Intercom push in host app

This only applies to applications that also use gcm for their own content.

All GCM receivers will receive the intent to create a new message from Intercom's library. To prevent trying to draw an Intercom gcm in the host app (which would create doubles) add the following line to your IntentService for GCM

Bundle extras = intent.getExtras(); 
if (extras.containsKey("receiver") && Intercom.GCM_RECEIVER.equals(extras.getString("receiver"))) {
    return;
}
Did this answer your question?