.enablePush()
This API can be used to extract and pass over your mobile app's push notification data to the embedded Zoho SalesIQ SDK.
PARAMETERS
Regid: The given device token.
Bool: (True/False) If the value is set to "True" then the devices will be displayed in the SalesIQ web SDK section to send and test the push notification in respective mode.
mode: .sandbox/.production
To setup push notification:
Step 1. To enable push notification in the SalesIQ SDK, conform AppDelegate to the UNUserNotificationCenterDelegate protocol and add the following block of code.
if #available(iOS 10.0, *) { let center = UNUserNotificationCenter.current() center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in center.delegate = self print("in del") } let categoryOptions = UNNotificationCategoryOptions(rawValue: 0) let reply = UNTextInputNotificationAction(identifier: "Reply", title:"Reply", options: [], textInputButtonTitle:"Send", textInputPlaceholder: "Message") let chatGrpMsgCategory_10 = UNNotificationCategory(identifier: "GRPCHATMSG", actions: [reply], intentIdentifiers: [], options: [categoryOptions]) UNUserNotificationCenter.current().setNotificationCategories([chatGrpMsgCategory_10]) application.registerForRemoteNotifications() } else { let settings:UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories:nil ) application.registerUserNotificationSettings(settings) }
Step 2. To enable push notification, select the mode: APNSMode.sandbox or APNSMode.production and include the following snippet in application: didRegisterForRemoteNotificationsWithDeviceToken.
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)}) ZohoSalesIQ.enablePush(deviceTokenString, isTestDevice: true,mode: APNSMode.sandbox) }
Note:At this stage you should make sure that you have enabled the Push Notification capability in Xcode.
Step 3. In your App Delegate file, include the following snippet to enable reply option to the corresponding received notification.
@available(iOS 10.0, *) func userNotificationCenter(_ center: UNUserNotificationCenter,didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { if ZohoSalesIQ.isMobilistenNotification(response.notification.request.content.userInfo){ switch response.actionIdentifier { case "Reply": ZohoSalesIQ.handleNotificationAction(response.notification.request.content.userInfo, response: (response as? UNTextInputNotificationResponse)?.userText) default: break } if response.actionIdentifier == UNNotificationDefaultActionIdentifier{ ZohoSalesIQ.processNotificationWithInfo(response.notification.request.content.userInfo) } } completionHandler() }
Step 4. You can easily test if your push notification is working in the app.
- To test manually, go to Settings->Website->Website Name->Live Chat for Mobile Apps.
- Choose iOS and then select sandbox.
- Enter the message and send.
- You will now receive a notification on your mobile phone.
Syntax:
CopiedZohoSalesIQ.enablePush(deviceTokenString, isTestDevice: true,mode: APNSMode.sandbox)
Example
Copiedfunc application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)})
ZohoSalesIQ.enablePush(deviceTokenString, isTestDevice: true,mode: APNSMode.sandbox)
}