Push Notification

Push Notifications#

To receive messages in the background or in the killed state, kindly register for remote notification by conforming to the following delegates in the AppDelegate UNUserNotificationCenterDelegate. Call the below methods when an APNS token gets updated.

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// APNS Token Update
VOIPManager.sharedInstance.saveAPNSToken(token: token)
TOKENApns Token

App Group Id#

In order to access data between app and notification extension, enabling app group is mandatory to access user defaults and database in container. So re-initialize the ChatSDK builder in didReceive method of the UNNotificationServiceExtension delegate.


To know more about ChatSDK Builder click here.

Process push notification request#

In class that extends the UNNotificationServiceExtension after validating whether the received payload is for Chat or not, call the below method to process the request further.

func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
NotificationMessageSupport.shared.didReceiveNotificationRequest("NOTIFICATION_CONTENT", "COMPLETION_BLOCK")
NOTIFICATION_CONTENTUNMutableNotificationContentNotification request content
COMPLETION_BLOCK(UNMutableNotificationContent?) -> VoidCompletion Block