ASAP for Mobile Platforms

Enabling Notifications

You can configure the ASAP add-on to send notifications to end-users when an agent responds via chat. The key component in making this possible in the SDK is an Apple Push Notification service (APNs) certificate in the .p12 format. 

To generate a .p12 file of the APNs certificate, perform the following steps.
  1. Create and download an APNs certificate from Apple's developer portal. 
  2. Double-click the certificate.  This action automatically imports it to the Keychain Access application.
  3. Locate and expand the certificate in Keychain Access.  The corresponding key for the certificate appears. 
  4. Select both the certificate and the key and right-click on them.  A context menu appears.
  5. Click the export option.  A dialog box appears. 
  6. In this dialog box, make sure that .p12 is selected in the File Format drop-down list and click Save
  7. Enter a password to access the file and click OK.  The certificate is now exported as a .p12 file. 

Next, you must enable push notifications in the Zoho Desk ASAP setup page. 

Here's how you do this. 

On the setup page for the add-on in Zoho Desk, upload the .p12 file you created and the password to access the file.

Next, configure the add-on to invoke the enablePushNotification: API call inside the application:didRegisterForRemoteNotificationsWithDeviceToken: method in the AppDelegate. 

To perform this configuration, include the following method in the app code. 

Swift

func application(_ application: UIApplication,didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  let token = deviceToken.reduce("", {$0 + String(format: "%02X", $1)}).uppercased()
  ZohoDeskPortalSDK.enablePushNotification(deviceToken:token, mode: .production)
}

Objective-C

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
    NSString * token = [[[[deviceToken description]
                                      stringByReplacingOccurrencesOfString: @"<" withString: @""]
                                     stringByReplacingOccurrencesOfString: @">" withString: @""]
                                    stringByReplacingOccurrencesOfString: @" " withString: @""];
    [ZohoDeskPortalSDK enablePushNotificationWithDeviceToken:token isTestDevice:NO mode:APNSModeProduction];
}

Note:

  • You can verify if notifications are sent accurately by testing the functionality in development mode. To switch to development mode, replace ".production" in the code snippet above with ".sandbox". 
  • Make sure to switch back to production mode before deploying the app for end-customer use.

Next, you must configure the SDK to automatically invoke the didReceiveRemoteNotification: method in the AppDelegate when a push notification is received. 

Then, for the SDK to process the notification received and perform the corresponding operation, the processRemoteNotification method in the SDK must be invoked with details of the notification, as follows.

Swift

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
  ZohoDeskPortalSDK.processRemoteNotification(userInfo: userInfo)
 }

Objective-C

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
    [ZohoDeskPortalSDK processRemoteNotificationWithUserInfo:userInfo];
}