Search code examples
iosswifttwiliocallvoice

Calling screen dismiss on accept the twilio voice call even app is active in swift 4


I’m using Twilio’s Programmable Voice in one of the projects. My primary requirement is to place VoIP class between mobile devices. I am able to place calls from one device to another,but when i accept the call at that time calling screen is dismiss automatically and call continue in background. In this case user do not have an option for disconnect call or any other action related to call because screen is dismissed.

Here is the screen that i have created for call when app is in foreground.

Caller screen

Calling placed success fully but on receiver accept it will dismiss the custom screen.So that user do not have any option to disconnect call or any other action related to call.

If any issue in code or any thing related to call kit setting i need to configure or any other issue ? Please help.


Solution

  • As per my knowledge this is default behaviour of call kit framework. On accept button click it will dismiss the screen when app is in foreground. If you wants to achieve same like whats app then you need to create a custom screen for that.Below code I did to resolve this issue:

     func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) 
     {
    
        NSLog("provider:performAnswerCallAction:")
        // TwilioVoice.configureAudioSession()
    
        let vc = loadVC(strStoryboardId: SB_CHAT, strVCId: idVoiceCallVC) as! VoiceCallVC
        vc.callername = name
        vc.userPhoto = userphoto
        APP_DELEGATE.appNavigation?.pushViewController(vc, animated: true)
        assert(action.callUUID == self.callInvite?.uuid)
        TwilioVoice.isAudioEnabled = false
        self.performAnswerVoiceCall(uuid: action.callUUID)
        { (success) in
            if (success)
            {
                action.fulfill()
    
            }
            else
            {
                action.fail()
            }
        }
        action.fulfill()
    }
    

    You just need to add your custom screen display code in this delegate method of call kit framework.

     func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {}
    

    Thanks.