Notifications iOS

Configure Push notifications and In-app notifications

Configure push notifications via Helpshift

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 badge or sound alert or both and appears with the App icon in the iOS Notification Center.

Configure Helpshift's push notification service in the Helpshift admin interface

Set up your application with Apple and enable push notifications. Download the Push Notifcation Certificate from Apple's developer portal, and double click on it to import it to the Keychain Access application.

In the Keychain Access application right click on the certificate that was just added and click export it in .p12 format. Please provide a password while exporting the certificate (We do not accept empty passwords). Note that if your development private key is not present in Keychain Access you will not be able to export it in .p12 format. Once you have exported the .p12 file you can login and upload that file in your app settings in the Helpshift admin panel. Provide the same password you used while exporting to .p12 format.

helpshift-push-notifications.png

Set the Production / Development mode options, depending on whether your Apple push certificate was for testing (development push) or production. You can configure whether to send a badge or not, and sound alerts if you provided custom sounds bundled with your app to handle notifications. Save it and you're all set.

Configure the Helpshift Xamarin SDK to handle notifications

For Helpshift SDK to work with the Helpshift push notification service you will need to invoke the HelpshiftApi.HelpshiftCore.RegisterDeviceTokenapi call inside the application delegate method RegisteredForRemoteNotifications In your app delegate file it will look something like this:

public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
    var DeviceToken = deviceToken.Description;
    HelpshiftCore.RegisterDeviceToken(deviceToken);
}

Whenever a push notification is received, the application delegate DidReceiveRemoteNotification gets called. Developers should check the "origin" field of the notification dictionary and call 'HelpshiftCore.HandlePushNotification' api if the origin of the notification is "helpshift". The Helpshift SDK will check issue for which the notification was received and will launch the chat screen for that issue automatically.

Example usage:

public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
    var DeviceToken = deviceToken.Description;
    HelpshiftCore.RegisterDeviceToken(deviceToken);
}

public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, System.Action<UIBackgroundFetchResult> completionHandler)
{
    NSObject originVal = userInfo.ObjectForKey((NSString)"origin");
    if (originVal != null && originVal.IsEqual((NSString)"helpshift"))
    {
        Console.WriteLine("notification is " + userInfo);
        HelpshiftCore.HandlePushNotification(userInfo);
    }
}

In-app notifications

In-app notifications are similar to Apple's push notification banners. Unlike push notifications, they appear within your app when it is in use by the user.

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

iOS Simulator Screen shot 16-Sep-2013 2.42.30 PM.png

iOS Simulator Screen shot 16-Sep-2013 2.42.55 PM.png

iOS Simulator Screen shot 16-Sep-2013 2.43.07 PM.png

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 HelpshiftApi;
.
.
.

Dictionary<string, string> config = new Dictionary<string, string>();
config.Add("enableInAppNotification","yes");
HelpshiftCore.Initialize(HelpshiftApiProviderType.HelpshiftApiProviderTypeAll);
HelpshiftCore.Install("apiKey","domainName","appId", 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

nint 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

nint 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.