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 Urban Airship

urbanAirshipNotif.png

Helpshift enables you to use Urban Airship to send notifications to your users. This is particularly useful when you have users on multiple platforms like iOS and Android. Urban Airship provides a common framework to notify your users on any platform. 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 links for Urban Airship account and documentation on GCM Push:-

For Helpshift admin interface

To enable the helpshift system to send push notifications to your users you will have to add your "Application Key" and "Application Master Secret" keys via the helpshift admin interface. If you have multiple apps within a single helpshift instance, you will have to create the same number of apps in Urban Airship. Enter your Urban Airship credentials per app, via the Settings page > App listing in the left navigation > Scroll down to Push Notifications settings section for the app.

urban-airship-push-notifications.png

You can check if your test device is registered via the admin panel on Urban Airship.

urban-airship-dev-token.png

Configure the Helpshift Unity SDK to handle notifications

In built support

Helpshift Unity plugin now comes with built-in support for Push notifications. If you want to use the Helpshift push notification handling, please call the HelpshiftSdk.registerForPush(string yourGcmSenderId) API inside your applications init code. Also you need to uncomment the permissions in the AndroidManifest for Helpshift. Go to Assets->Plugins->Android->helpshift->AndroidManifext.xml. Uncomment the following permissions :

<!-- App receives GCM messages. -->
<!--permission android:name="<YOUR_APP_BUNDLE_IDENTIFIER>.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="<YOUR_APP_BUNDLE_IDENTIFIER>.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /-->
<!-- GCM requires a Google account. -->
<!--uses-permission android:name="android.permission.GET_ACCOUNTS" /-->
<!-- Keeps the processor from sleeping when a message is received. -->
<!--uses-permission android:name="android.permission.WAKE_LOCK" /-->

<!--receiver android:name="com.helpshift.gcm.HSGcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
        <category android:name="<YOUR_APP_BUNDLE_IDENTIFIER>" />
    </intent-filter>
</receiver>
<service android:name="com.helpshift.gcm.HSGcmIntentService" /-->

Replace <YOUR_APP_BUNDLE_IDENTIFIER> with your app's bundle identifier here.

Manual support

If you have integrated push notifications to receive updates from the Helpshift's push notification service, please use the HelpshiftSdk.registerDeviceToken(string deviceToken) API to register the device token with the Helpshift SDK.

Once this is done, you can use the HelpshiftSdk.handlePushNotification(Dictionary<string, object> pushNotificationData) API to send the payload received in the notification.

To check whether this notification is being sent from the Helpshift's push notification service, please check the origin field of the notification. If it is "helpshift", the notification is a Helpshift notification. For example

GCM.SetRegisteredCallback ((string registrationId) => {
        help.registerDeviceToken(registrationId);
});

GCM.SetMessageCallback ((Dictionary<string, object> table) => {
        if(table["origin"].Equals("helpshift")) {
                help.handlePushNotification((table);
        }
});

Support with other push notification plugins

If you are using any other plugin for push notifications like prime31,onesignal etc. you can use HelpshiftSdk.registerDeviceToken(string deviceToken) API to register the device token. You need to call this API from the registrationSucceededEvent in your plugin. The following is an example for prime31 plugin.

For Example :

void registrationSucceededEvent( string registrationId )
{
    Debug.Log( "registrationSucceededEvent: " + registrationId );
    HelpshiftLog.e ("Helpshift-HS", registrationId);
    help.registerDeviceToken (registrationId);
}

Once this is done, you can use the HelpshiftSdk.handlePushNotification(Dictionary<string, object> pushNotificationData) API to send payload which you receive in the notificationReceivedEvent callback in your plugin.

To check whether this notification is being sent from the Helpshift's push notification service, please check the origin field of the notification. If it is "helpshift", the notification is a Helpshift notification.

If you are using other push notification service do not uncomment the permissions in the Helpshift AndroidManifest.

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 notifications support provided by the Helpshift SDK, please set this flag to "no". The default value of this flag is "yes" i.e in-app notifications will be enabled.
Read more about in-app notifications in the Notifications section.

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

Example:

using Helpshift;
.
.
.
private HelpshiftSdk help;
this.help = HelpshiftSdk.getInstance();
Dictionary<string, string> configMap = new Dictionary<string, string>();
configMap.Add("unityGameObject", "DemoControl");
configMap.Add("enableInAppNotification", "yes");
help.install("<YOUR_API_KEY>", "<YOUR_HELPSHIFT_DOMAIN>", "<YOUR_APP_ID>", configMap);

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

Integer notifCount = helpshift.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

helpshift.getNotificationCount(true);

In such a scenario, the return value of the function should be ignored. To get the actual count of unread notifications, you should implement the didReceiveNotificationCount message handler on the Game object which you have registered at the time of install.

For example

public void didReceiveNotificationCount(string count) {
    Debug.Log("Notification async count : " + count);
}

Via In-App Notifications

If you want to use the in-app notifications mechanism to get the count of unread notifications, you can implement the didReceiveInAppNotificationCount message handler on the Game object which you have registered at the time of install.

For example

public void didReceiveInAppNotificationCount(string count) {
    Debug.Log("In-app Notification count : " + count);
}