Push

Set up push notifications.

APNS certificate

To use push notifications with this SDK, you have to provide APNS Key and upload it to our Sinch Panel.

Xcode Capabilities

Make sure you’ve enabled the Remove notifications capability in Background Modes in your target configuration in the tab Signing & Capabilities and the Push Notifications tab.

Methods in AppDelegate.swift or AppDelegate.m:

Copy
Copied
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

SinchChatSDK.shared.push.sendDeviceToken(deviceToken)

}

Make sure you’ve added UNUserNotificationCenterDelegate to AppDelegate definition or to you own class.

swiftswift
Copy
Copied
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {



if SinchChatSDK.shared.push.handleNotificationResponse(response) {

// this is our notification and it is handled by SinchChatSDK

}



completionHandler()

}
Copy
Copied
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {



if let presentationOptions = SinchChatSDK.shared.push.handleWillPresentNotification(notification) {

completionHandler(presentationOptions)

return

}

completionHandler([])

}
We'd love to hear from you!
Rate this content:
Still have a question?
 
Ask the community.