Push Notification Settings

How to configure Push notifications for iOS SDK in SalesIQ?

Step1: In the Zoho SalesIQ console, navigate to Settings > Brands > {Your brand name} > Installation > iOS, scroll down to Configure push notifications section. and enable push notification for Sandbox or Production mode.

You have two environments available for the push notifications settings:

  • Production: You are to use production mode if your application is being deployed in the production environment to customers.

  • Sandbox: You can use the sandbox environment to test and debug the modifications before moving to production mode for deployment.

APNs Certificate (P12)

You must create and upload a valid Apple Push Notification service (APNs) certificate to send push notifications to your application users. The APNs forwards notification of SalesIQ applications to the Apple devices.

How to generate the APNs certificate?

  1. Log in to the iPhone Developer Connection Portal and click on the iOS Provisioning Portal on the page's right side.
  2. On the welcome page, click on the Identifiers section to open the list with identifiers.
  3. To create a new App ID, open the App IDs tab and click on the New App ID button. Enter your app name for the Description, and enter the Bundle Identifier.
  4. Ensure you have created an App ID without a wildcard. Wildcard IDs cannot use the push notification service.
  5. Then, click on the Submit button.
  6. You can enter the notification text in the message and click the Send button to test. The Registered mobile devices will receive your test notification message.  Upload the APNS Certificate(P12) for the respective modes by clicking the Upload button, as shown.

 

APNs Password

The APNs certificate would demand a password while configuring. Provide the same password of your APNs certificate here for authentication.

Test the push notification on your registered mobile devices

To test the push notification service, you can register your testing mobile devices here. Upon registering, the device will be added to the list of registered devices, and push notifications can be sent using the Send button.

How to register your mobile device?

Note:

You should make sure that you have enabled the Push Notification capability for the project in Xcode.

Step 1: To enable push notification in your Cordova/Ionic project, conform AppDelegate to use the UNUserNotificationCenterDelegate protocol. Import the following in your AppDelegate.h files.

Copied #import <UserNotifications/UserNotifications.h>
#import <UserNotifications/UNUserNotificationCenter.h>
#import <Mobilisten/Mobilisten.h>

Add the following block of code within the application:didFinishLaunchingWithOptions method in the AppDelegate.m file.

Copied  if (@available(iOS 10.0, *)) {
       UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
       [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error) {
         center.delegate = self;
         if (granted){
           dispatch_async(dispatch_get_main_queue(), ^{
            UNNotificationCategoryOptions categoryOptions = UNNotificationCategoryOptionNone;
            UNTextInputNotificationAction *reply = [UNTextInputNotificationAction actionWithIdentifier:@"Reply" title:@"Reply" options:@[] textInputButtonTitle:@"Send" textInputPlaceholder:@"Message"];
            UNNotificationCategory *chatGrpMsgCategory_10 = [UNNotificationCategory categoryWithIdentifier:@"GRPCHATMSG" actions:@[reply] intentIdentifiers:@[] options:categoryOptions];
            [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObjects:chatGrpMsgCategory_10,chatGrpMsgCategory_10, nil]];
            [application registerForRemoteNotifications];
             [application registerForRemoteNotifications];

           });
         }
       }];
  }
  else{
       UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound) categories:nil];
       [application registerUserNotificationSettings:settings];
  }

Step 2: To register the device with SalesIQ for push notifications, the enablePush API needs to be called. Insert the code within the application:didRegisterForRemoteNotificationsWithDeviceToken method in the  AppDelegate.m file.

Copied  const char *data = [deviceToken bytes];
NSMutableString *token = [NSMutableString string];
for (NSUInteger i = 0; i < [deviceToken length]; i++) {
  [token appendFormat:@"%02.2hhX", data[i]];
}
[ZohoSalesIQ enablePush:token isTestDevice:YES mode:APNSModeSandbox];
// Set APNS mode to APNSModeProduction and isTestDevice to NO before deploying the application in Production. 

Step 3: In your AppDelegate.m file, include the following code in the center:didReceiveNotificationResponse method.

Copied if (@available(iOS 10.0, *)) {
  if ([ZohoSalesIQ isMobilistenNotification:response.notification.request.content.userInfo]) {
     if ([response.actionIdentifier isEqualToString: @"Reply"]) {
         [ZohoSalesIQ handleNotificationAction:response.notification.request.content.userInfo response:((UNTextInputNotificationResponse *)response).userText];
     }
    else if([response.actionIdentifier isEqualToString: UNNotificationDefaultActionIdentifier]){
         [ZohoSalesIQ processNotificationWithInfo:response.notification.request.content.userInfo];
    }
  }
}

Step 4: Insert the code block within application:didReceiveRemoteNotification method in the AppDelegate.m file.

Copied  [ZohoSalesIQ processNotificationWithInfo:userInfo];

Step 5: In your AppDelegate.m file, include the following code within application:didReceiveLocalNotification method 

Copied  [ZohoSalesIQ processNotificationWithInfo:notification.userInfo];

Step 6: Include the following code within center:willPresentNotification method in the AppDelegate.m file.

Copied  [ZohoSalesIQ processNotificationWithInfo:notification.request.content.userInfo];

Upon successful registration, the registered iOS device will be visible in the list of registered devices, as shown below.

  • You can easily test if your push notification is working in the app. To test manually, go to the Settings > Brands > {Your brand name} > Installation > iOS.
  • Select Sandbox and scroll down to Configure push notification section. If your device is registered correctly and listed in the list of registered devices, enter the message in the Test push notification input field and click Send. You will now receive a notification with your content on your registered iOS device.

You also have an option to delete the registered test devices.

Note:

If you delete a test device from the list of registered devices, any test notifications sent from the test page would not be sent to the removed device. Any other notifications from SalesIQ would still be received.