Option 1: FCM

If you haven’t already integrated FCM, do so by following the instructions here

After following FCM steps for integration, follow these 2 steps to connect Hotline and FCM

Step 1. Send Registration Token

In the app’s implementation of  FirebaseInstanceIdService, send the token to Hotline as follows 

@Override
public void onTokenRefresh() {
    String token = FirebaseInstanceId.getInstance().getToken();
    Hotline.getInstance(this).updateGcmRegistrationToken(token);
}

  

Step 2 : Handle FCM Message

In the app’s implementation of  FirebaseMessagingService, pass the RemoteMessage object to Hotline if it is a Hotline notification. 

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        if (Hotline.isHotlineNotification(remoteMessage)) {
            Hotline.getInstance(this).handleFcmMessage(remoteMessage);
        } else {
            //Handle notifications with data payload for your app
        }
    }

 

Option 2 : GCM

Please update the Hotline SDK with your GCM registration token once it becomes available.”

Step 1. Send Registration Token

In the app’s implementation of InstanceIDListenerService’s onTokenRefresh() method or the GcmRegistrationService

Hotline.getInstance(context).updateGcmRegistrationToken(token);

 

Step 2: Handle GCM Message

In the app’s implementation of GCMListenerService’s onMessageReceived, pass the instance of the Bundle received as a parameter in onMessageReceived to Hotline if it is a Hotline notification.

@Override
protected void onMessageReceived(String from, Bundle data) {
{
	Hotline instance = Hotline.getInstance(this);
	if(instance.isHotlineNotification(data)) {
		instance.handleGcmMessage(data);
		return;
	} else {
		// Your application code goes here to handle other kinds of messages
	}
}

 

Debugging Android Push - See this if your responses aren't instantaneous


a. Find if we get a push registration token from the device or not (Push Enabled = YES vs NO on the conversation web interface with a new conversation from an app install)
NO:
(1) Manifest issue 
- make sure all permissions are in place 
- make sure manifest isn't suggesting any errors (appears in red in some cases)
- make sure you replace "YOUR_PACKAGE" in the instructions with your package name 
- make sure manifest merging is enabled if it is a library project integration
(2) Code issue
- if you had an existing implementation of push which continues to work, make sure you are sending the registrationID to Hotline  (Hotline.getInstance(context).updateGcmRegistrationToken(regId);)
- if this is a completely new implementation, make sure you have placed all the classes DIRECTLY UNDER YOUR BASE PACKAGE. 
- place debug statements to see if the methods to register and receive push are being called
YES:
(1) API key issue - if you use your own project ID/sender ID for GCM
- make sure you have set the right GCM Server API key (not GCM Android key) on the android integration instructions page with Hotline and that there are no leading/trailing spaces

- remember the API key is a long string of characters and not your project ID (a shorter number usually) - you obtain this server API key from the "Credentials" section under your project on the Google Developer Console

(2) Code issue 
- make sure you have the snippet that invokes Hotline.getInstance(context).handleGcmMessage(data) as part of your onMessageReceived
- add debug statements to find where the problem might lie.

(3) IP Whitelisting

- If you use a whitelist of IPs for your server APIs now, please ensure that it contains our IPs (reach out to support@hotline.io for the IPs).