1

This problem has been plaguing me for about two weeks. I haven't been able to find anything on SO, Apple's Documentation, or the Apple Developer Forums that has directly answered this question. I've built out a VoIP capable app, and implemented PushKit, CallKit, and the CXProviderDelegate which all work just fine in the app. However, if a user receives a call after they've terminated their app the call will come in fine in regards to CallKit and the CXCallController displaying the native call UI of iOS but once the user answers the call it opens the app (if the device is unlocked, or opens the app as soon as the device becomes unlocked) but I can't find a means to open the app to the Call UI I've designed.

I'm not sure where I need to display the Call UI. I tried to build some logic into my rootViewController (which is my LoginVC) to check to see if their is an active call in the viewDidAppear(_:), however this function doesn't seem to be called when the app is opened in such a way.

I've consulted these tutorials and SO articles: (None of which references this particular case)

Ray Wenderlich's CallKit Tutorial

CallKit iOS Swift Tutorial for VoIP Apps

Switching from CallKit UI to in-app UI

How to display a ViewController when answering a call with CallKit

1 Answers1

1

When the user answers the call, the app has been already launched in the background.

What I would do is to trigger an action (e.g. with a callback or using NotificationCenter) inside the provider(_:perform:) method of the CXProviderDelegate that will then present your call UI.

func provider(_ provider: CXProvider, perform action: CXAnswerCallAction)
{
    guard callManager.callWithUUID(action.callUUID) != nil else {
        action.fail()
        return
    }
    presentCallUICallback(completion: { action.fulfill() })
}
Marco
  • 1,572
  • 1
  • 10
  • 21
  • Thanks for your help! I found my issue, and unfortunately it was a logic mistake on my behalf. I am using Touch/FaceID on my first VC after launch, and the logic (which was wrong) that was performed during that process was preventing my call screen from being displayed. Once I fixed the logic, everything worked smoothly. I still don't full understand why the logic was preventing the VC from being displayed, but it works now. – Brett Chapin Jun 17 '20 at 14:08
  • @BrettChapin I'm new to this and still checking tutorials, and searching for something to do same functionality as you, when the user answers, I need to open my app even if the device is locked. Could you please share with me how to do that? – EnasAZ Aug 03 '20 at 15:40
  • 1
    @EnasAZ When the phone is locked and you get a call from CallKit, the app is already opened on the background and CallKit UI is visible on top. To see the app, the user needs to press a button on CallKit. But when the phone is NOT locked, the app opens automatically when you answer the call. – Tanay Mondal Sep 02 '20 at 14:51