Reputation: 95
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
Upvotes: 1
Views: 507
Reputation: 1676
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() })
}
Upvotes: 1