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.

If the GCM/FCM device token is registered for push notifications, then in-app notifications will be disabled. In-app notifications are disabled to avoid duplicate notifications from both push notifications and in-app notifications.

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 sent by an Agent to their open Issues, you can use notification counts provided by the Helpshift SDK. These notification counts give you the total number of unread messages and display it as a badge. You can get notification counts asynchronously by implementing the Helpshift delegate method "DidReceiveUnreadMessageCount" . Notifications are typically displayed as badges inside your app where a user clicks on the help section. These badges can be displayed anywhere in your app's interface to tell the user that they have unread replies/messages from you.

For example

HelpshiftApi.HelpshiftSupport.RequestUnreadMessagesCount(false);

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

For example

HelpshiftApi.HelpshiftSupport.RequestUnreadMessagesCount(true);

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