Home / IOS Development / fast – Twilio voice calls do not go to the custom page in iOS

fast – Twilio voice calls do not go to the custom page in iOS



I use Twilio for voice call functionality in my iOS application. If the app is in an active state or running in the background, it goes perfectly to my custom conversation page, and I can take proper action from my custom page such as disconnecting or something. But in case of idle or not running in the background, it does not come to a custom talk page or can not do anything as a link from there. Suggest what I̵

7;m 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()
            }
        }
    }


Source link