Push Notification Settings
How to configure Push notifications for iOS SDK in SalesIQ?
Step1: In the Zoho SalesIQ dashboard, navigate to Settings > Brands > Installation -> iOS -> Configure push notification and click on the toggle to 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?
- Log in to the iPhone Developer Connection Portal and click on the iOS Provisioning Portal on the right side of the page.
- On the welcome page, click on the Identifiers section, to open the list with identifiers.
- 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 Bundle Identifier.
- Ensure, you have created an App ID without a wildcard. Wildcard IDs cannot use the push notification service.
- Then, click on Submit button.
- 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 in 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 react-native 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 <RNZSIQNotifications.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];
});
}
}];
}
else{
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound) categories:nil];
[application registerUserNotificationSettings:settings];
}
if(launchOptions[@"UIApplicationLaunchOptionsRemoteNotificationKey"] != nil){
NSDictionary *notificationData = launchOptions[@"UIApplicationLaunchOptionsRemoteNotificationKey"];
if(notificationData != nil){
[RNZSIQNotifications processNotificationWithInfo:notificationData];
}
}
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]];
}
[RNZSIQNotifications enablePush:token isTestDevice:YES isProductionMode:NO];
/*
Note: isTestDevice is set to be as YES if device is being registered as a test device in sandbox mode.
*/
Step 3: In your AppDelegate.m file, include the following code in the center:didReceiveNotificationResponse method.
Copied
if (@available(iOS 10.0, *)) {
if ([RNZSIQNotifications isMobilistenNotification:response.notification.request.content.userInfo]) {
if ([response.actionIdentifier isEqualToString: @"Reply"]) {
[RNZSIQNotifications handleNotificationAction:response.notification.request.content.userInfo response:((UNTextInputNotificationResponse *)response).userText];
}
else if([response.actionIdentifier isEqualToString: UNNotificationDefaultActionIdentifier]){
[RNZSIQNotifications processNotificationWithInfo:response.notification.request.content.userInfo];
}
}
}
Step 4: Insert the code block within application:didReceiveRemoteNotification method in the AppDelegate.m file.
Copied
[RNZSIQNotifications processNotificationWithInfo:userInfo];
Step 5: In your AppDelegate.m file, include the following code within application:didReceiveLocalNotification method
Copied
[RNZSIQNotifications processNotificationWithInfo:notification.userInfo];
Step 6: Include the following code within center:willPresentNotification method in the AppDelegate.m file.
Copied
[RNZSIQNotifications 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 > Website > Website Name > Live Chat for Mobile Apps.
Choose iOS and then select Sandbox. If your device is registered correctly and listed in the list of registered devices, enter the message in the testing text box 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.