Notifications Android

Configure Push and In-app notifications.

Configure push notifications via Helpshift

urbanAirshipNotif.png

Helpshift enables you to send notifications to your users. This is particularly useful when you have multiple users on multiple platforms like iOS and Android. Notifications are useful to tell your users when you reply to an issue that they submitted. When the app is backgrounded, the notification that is sent from Helpshift appears as a notification.

Refer to the following link for documentation on GCM Push:- Google Cloud Messaging for Android

For Helpshift Admin Interface

To enable the Helpshift system to send push notifications to your users you will have to add your GCM Key and Bundle Name via the helpshift admin interface.

Enter your Google Push notifications credentials per app, via the Settings page > App listing in the left navigation > Scroll down to Push Notifications settings section for the app.

helpshift-push-notifications.png

The API key can be found at your Google API Console.

GCM Console.png

Configure the Helpshift Xamarin SDK to handle notifications

Prerequisites

Implement GCM push in your app. Refer to the Google Cloud Messaging for Xamarin Android documentation.

Configure Helpshift Android SDK

  1. Send the device registration id to Helpshift via the HelpshiftApi.HelpshiftCore.RegisterDeviceToken API

    HelpshiftApi.HelpshiftCore.RegisterDeviceToken(token);
    
  2. Inside your GcmBroadcastReceiver's OnMessageReceived method check "origin" is "helpshift" and pass the bundle data to Helpshift.HandlePushNotification API

    public override void OnMessageReceived(Context context, Bundle bundle) {
      string origin = bundle.GetString("origin");
      if(origin != null && origin.equals("helpshift")) {
        HelpshiftApi.HelpshiftCore.HandlePushNotification (data);
      }
    }
    

In-app notifications

In-app notifications are similar to notifications in the notification drawer . Unlike push notifications, they appear only when you app is running.

These notifications are sent when an agent replies to a customer's issue. Your customers can go straight into the conversation screen when they tap on the notification.

Configuring in-app notifications

If you do not want the in-app notification support provided by the Helpshift SDK, you can set the flag to "no". The default value of this flag is "yes" i.e., in app notification will be enabled.

  • Flag: enableInAppNotification
  • Values: "yes"/"no"
  • Default: "yes"

Example:

Dictionary<string,object> config = new Dictionary<string,object>();
config.Add("enableInAppNotification", "yes");
HelpshiftCore.Initialize(HelpshiftApiProviderType.HelpshiftApiProviderTypeAll);
HelpshiftApi.HelpshiftCore.Install ("<YOUR_API_KEY>",
                  "<YOUR_COMPANY>.helpshift.com",
                  "<YOUR_APP_ID>",
                  config);

Showing notification count when replies are sent to the user

Via Helpshift API

If you want to show your user notifications for replies on the issues posted, you can get the notification count synchronously from cache.

For example

int notifCount = HelpshiftSupport.GetNotificationCount(false);

If you want to fetch the notification count from the server asynchronously, you can pass call the GetNotificationCount API with a true param value.

For example

int notifCount = HelpshiftSupport.GetNotificationCount(true);

You will receive the callback with the notification count in the delegate registered using HelpshiftSupport.SetDelegate() api in DidReceiveNotificationCount method. Refer Support delegates.