Monday, 12 October 2020

Twilio voice call not going to custom page in IOS

I am using Twilio for voice call functionality in my IOS application. If the app is in an active state or running in the background its perfectly going to my custom call page and I can take proper action from my custom page like disconnect or something. But in the case of inactive state or not running in the background it's not going to custom call page or can't able to take action like a disconnect from there. Please suggest what I am missing here

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
        NSLog("pushRegistry:didReceiveIncomingPushWithPayload:forType:completion:")
        
        // The Voice SDK will use main queue to invoke `cancelledCallInviteReceived:error:` when delegate queue is not passed
        
        if let rootViewController = UIApplication.topViewController() {

            let nextViewController = UIStoryboard(name: “Voice”, bundle: nil).instantiateViewController(withIdentifier: “VoiceCallViewController”)
            audioDevice = DefaultAudioDevice()
            callKitCallController = CXCallController()
            audioDevice.isEnabled = false
            audioDevice.block()
            nextViewController.audioDevice = audioDevice
            TwilioVoice.audioDevice = audioDevice
            nextViewController.fromAppDelegate = true
            nextViewController.callKitProvider = callKitProvider
            nextViewController.callKitCallController = callKitCallController
            callKitProvider!.setDelegate(nextViewController, queue: nil)
            self.pushKitEventDelegate = nextViewController
            
            if let delegate = self.pushKitEventDelegate {
                delegate.incomingPushReceived(payload: payload, completion: completion)
                rootViewController.navigationController?.pushViewController(nextViewController, animated: true)
            }
            
            if let version = Float(UIDevice.current.systemVersion), version >= 13.0 {
                /**
                 * The Voice SDK processes the call notification and returns the call invite synchronously. Report the incoming call to
                 * CallKit and fulfill the completion before exiting this callback method.
                 */
                completion()
            }
        }
    }


from Twilio voice call not going to custom page in IOS

No comments:

Post a Comment