Launching CallVC when CallKit call is answered

I have PushKit and CallKit working within my application, it is working as I would expect it to with one exception; When a user has their app terminated, and an incoming call is answered by the user it opens the app but not to the CallVC that I have designed. How do I navigate it to the appropraite screen when the app is launched based on a CallKit answer action? Also, I noticed that the viewDidAppear(_:) print statement on the rootViewController of the AppDelegate's window (which is my LoginVC) does not happen when the app is launched this way, so I am not sure at one point to navigate to the proper view controller.

Replies

This isn't something CallKit (or any of our other frameworks) will do "automatically". The system doesn't know how your UI is intended to flow, so you need to manage presenting whatever UI you feel is appropriate. My own view here is that you DON'T necessarily want to shift the UI around at the point the call is answered. The user may not open your app during the call, in which case you're just creating a lot of unnecessary work and wasted memory shuffling around UI the user never even saw. I would keep all of your call handling code seperate from your interface and the shift your app to the correct state (based on whatever the user is actually doing at the time) in applicationWillEnterForeground.


In terms "viewDidAppear" not being called, the answer is basically "yes". Your view was never actually on screen, so viewDidAppear wasn't called.


-Kevin