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.

Development (Sandbox) mode vs. Production mode

When you build and run your app from Xcode, it is in development (Sandbox) mode. To test push notifications from Helpshift in this mode make sure you choose 'Development Mode' while uploading either of the above two certificate types.

When you publish your app and download from App Store, your app is in Production mode. To test push notifications from Helpshift in production mode make sure you choose 'Production Mode' while uploading a certificate of 'Apple Push Notification service SSL (Sandbox & Production)' type. Sandbox mode certificate will not work on a production environment.

We do not support using the same certificate for both sandbox and production apps. In these cases we recommend you create two separate apps on our dashboard, one in 'Production mode' and the other in 'Development mode'. While testing please use the credentials of the developement mode app. When you are ready to publish, please replace the credentials with those of the production level app.

Your Push Certificate has an expiry date, as indicated in the below screenshot. Helpshift will not send you a reminder when your Push Certificate expires, so please make sure that your developer keeps a tab on the expiry date to reupload the Push Certificate.

password-expiry.png

Configure the Helpshift Unity SDK to handle notifications

In built support

Helpshift Unity plugin comes with built-in support for Push notifications.

If you want to use the Helpshift push notification handling, please register your application to receive push notifications. The Helpshift SDK overrides the UnityAppController class to listen to the application delegates for Push notifications and calls the appropriate Helpshift APIs. If you already have a UnityAppController child class, please make sure it inherits from the HsUnityAppController class.

Manual support

For Helpshift SDK to work with the push notification service you will need to invoke the [HelpshiftCore registerDeviceToken:] API call inside the application delegate method didRegisterForRemoteNotificationsWithDeviceToken. You can find the function overridden inside the HsUnityAppController.mm class.

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
    [HelpshiftCore registerDeviceToken:deviceToken]
}

Whenever a push notification is received, the application delegate for notification received gets called. Additionally:

  • If the application was not in the foreground, and the user taps the push notification, this method is called again.
  • In cases where the app might have been killed by the user, and then they tap on a push notification, the application's didFinishLaunchingWithOptions: delegate is called.

The isAppLaunch boolean flag here is used to distinguish between an active or backgrounded app vs. an app that was killed by the user. In the latter case, this flag should be set to true.

If a push notification is received and if the app is in killed state, call the handleRemoteNotification:isAppLaunch:withController: in application:didFinishLaunchingWithOptions: function in UnityAppController or HsUnityAppController after unity is initialized.

Example usage:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    ...
    if(launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {
        NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
        if([[userInfo objectForKey:@"origin"] isEqualToString:@"helpshift"]) {
            [HelpshiftCore handleRemoteNotification:userInfo
                                        isAppLaunch:true
                                     withController:self.window.rootViewController];
        }
    }
    ...
}

Helpshift install call should be made before calling this method.

For the didReceiveRemoteNotification delegate

- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    if([[userInfo objectForKey:@"origin"] isEqualToString:@"helpshift"]) {
        [HelpshiftCore handleRemoteNotification:userInfo
                                    isAppLaunch:false
                                 withController:self.window.rootViewController];
    }
}

Applicable to SDK version 2.7.0 and above.

If the "origin" field of the notification dictionary is "helpshift", call HelpshiftSdk.handlePushNotification(Dictionary<string, object> pushNotificationData) api with the notification dictionary. The Helpshift SDK will launch the appropriate screen based on the action on notification click.

In-app notifications

Applicable to SDK version 2.4.0-rc-1 and above

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.

In-app Notifications on iOS 7

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

In-app Notifications on iOS 6

inapp_new.PNG

inapp_more.PNG

inapp_notif_center.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" or "no"
Default
"yes"

Example:

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("<API_KEY>", "<DOMAIN_NAME>", "<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);
}