Push Notification

Overview#

We use VOIP services of apple to receive calls in the background and in killed state.

Prerequisites#

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

In your Appdelegetae, register for voip notification by conforming to the following delegates PKPushRegistryDelegate.

Goto Project -> Target -> Signing & Capabilities -> Click + at the top left corner -> Search for the capabilities below
Capabilities
Voice over IP

Capabilities-voip

Update VOIP token#

Update your VOIP token using the below methods when an VOIP token gets updated.

    func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
    //VOIP Token Update
    let deviceToken = pushCredentials.token.reduce("") { $0 + String(format: "%02X", $1) }
    VOIPManager.sharedInstance.saveVOIPToken(deviceToken)
    VOIPManager.sharedInstance.updateDeviceToken()
    }
    ArgumentDescription
    TOKENApns or Voip Token

    Updating Push & VoIP Tokens with updateDeviceToken#

    After saving your VoIP token using the delegate method, you need to update both VoIPand APNs push tokens to ensure calls and notifications are delivered correctly.
    The SDK provides a helper method updateDeviceToken for this purpose.

      func updateDeviceToken(isForceUpdate: Bool = false, onCompletion: @escaping (_ isSuccess: Bool, _ updatedVOIPToken: String, _ updatedDeviceToken: String, _ tokenError: String?) -> Void) {
      }
      ArgumentDescription
      isForceUpdateSet to true to force update even if tokens haven’t changed. Default is false.
      isSuccessReturns true if update succeeded, else false.
      updatedVOIPTokenThe latest registered VoIP token.
      updatedDeviceTokenThe latest registered APNs push token.
      tokenErrorError details if update fails.

      Process VOIP request#

      With the didReceiveIncomingPushWith method, you will receive the call payload. In order to continue processing the call, you must send the payload to the SDK method below.

        func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
        VOIPManager.sharedInstance.processPayload("PAYLOAD", "DISPLAY_NAME")
        }
        ArgumentDescription
        PAYLOADPayload Dictionary
        DISPLAY_NAMEOptional Name parameter to set the caller's name when reporting to CallKit.

        |