Push Notification

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.

Note: Please upload your APNS and VOIP Certificate to our Console. To know more how to generate and upload APNS and VOIP Certificate Click Here

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

    App Group Id#

    To receive messages in the background or in the killed state, You need to enable app group container ID. And pass in below method.

    In order to access data between app and notification extension, enabling app group is mandatory to access user defaults and database in container.

    Capabilities

    Process push notification request#

    let CONTAINER_ID = "xxxxxxxxxxxxxxxxxxxxxx"

    Parameter Description#

    FunctionParameter TypeDescription
    CONTAINER_IDStringCreate App groups and assign the obtained group container id. SDK uses this string to create the path for the local storage.
    caution

    In order your changing existing app group container may occur data loss.

    Need to set CONTAINER_ID in Appdeleagte class. Thus, we utilize the usage of the setAppGroupContainerId method to access user defaults and database in container for UNNotificationServiceExtension.

      func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
      ChatManager.setAppGroupContainerId(id: CONTAINER_ID)
      ChatManager.initializeSDK(licenseKey: LICENSE_KEY) { _, _, _ in }
      return true
      }

      Call the setAppGroupContainerId method again in didReceive method of the UNNotificationServiceExtension delegate.

      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) {
        ChatManager.setAppGroupContainerId(id: CONTAINER_ID)
        NotificationMessageSupport.shared.didReceiveNotificationRequest("NOTIFICATION_CONTENT", "COMPLETION_BLOCK")
        }
        ArgumentTypeDescription
        NOTIFICATION_CONTENTUNMutableNotificationContentNotification request content
        COMPLETION_BLOCK(UNMutableNotificationContent?, ChatMessage?) -> VoidCompletion Block
        CONTAINER_IDStringPass group container id of the project that stores UserDefaults and Database

        Notification