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.

To know more about the FCM Push, refer:- Firebase 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.

FCM Console.png

Configure the Helpshift Xamarin SDK to handle notifications

Prerequisites

Implement FCM push in your app. Refer to the Firebase Cloud Messaging for Xamarin Android documentation.

Configure Helpshift Android SDK

  • When push is not configured, Helpshift SDK shows out-of-the-box "in-app notifications" for every message sent by Agents/Bots. You should call HelpshiftApi.HelpshiftCore.RegisterDeviceToken() API only after you have configured the Helpshift dashboard for push notifications. Calling the HelpshiftApi.HelpshiftCore.RegisterDeviceToken() API without configuring the Helpshift dashboard will stop showing out-of-the-box "in-app notifications" for the end users.
  1. Send the device registration id to Helpshift via the HelpshiftApi.HelpshiftCore.RegisterDeviceToken API

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

Applicable to version 3.0.0 and above.

    :::csharp
    public override void OnMessageReceived(RemoteMessage message)
    {
        IDictionary<string, string> data = message.Data;
        string origin = data["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:

HelpshiftInstallConfig config = new HelpshiftInstallConfig.Builder()
                                                          .SetEnableInAppNotifications(true)
                                                          .Build();
HelpshiftCore.Initialize(HelpshiftApiProviderType.HelpshiftApiProviderTypeSupport);
HelpshiftCore.Install ("<API_KEY>", "<DOMAIN_NAME>", "<APP_ID>", config);

Applicable to version 3.0.0 and above.

Dictionary<string,object> config = new Dictionary<string,object>();
config.Add("enableInAppNotification", "yes");
HelpshiftCore.Initialize(HelpshiftApiProviderType.HelpshiftApiProviderTypeSupport);
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);

The notification count is fetched via this API from the SDK cache and Helpshift's servers. However, the count from Helpshift’s servers is rate limited and it returns the value only if a subsequent call is made to the API, after the reset timeout or when the user just closes the chat screen (whichever is earlier). For an active issue, the reset timeout is 1 minute and 5 minutes for inactive issues.

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