Switching from in-app UI to CallKit UI during two ongoing calls with one on hold

1k Views Asked by At

I'm working on a Voip app and integrated CallKit. I know the CallKit UI will not show when there's incoming Voip calls, however the problem is when there's an ongoing Voip call and phone call at the same time (one on hold). You can test the below using Whatsapp.

  1. Start Voip call
  2. During the call, someone calls the phone using non internet sim/phone line
  3. CallKit UI shows up, with options to decline, end, or hold the voip call to answer the incoming phone call
  4. Select 'hold and answer', callkit UI shows two calls, with the voip call being hold
  5. Go back to the Voip app either by pressing the swap button and then the app icon (on the callkit UI itself), or by pressing going to home screen and click on app icon
  6. Voip app shows, there's a green bar on top that says 'Touch to return to call', I want to be able to go back to CallKit UI screen when user taps it (same as whatsapp).

If you test this on whatsapp you will know what I mean, I want to achieve the same behaviour.

whatsapp call screen with green bar CallKit UI with two calls

I have implemented the top green bar following this post: How to show double height green statusbar (In-Call) in foreground app on device?

However I couldn't find a way to programmatically bring the CallKit UI back to the front, the answer in that post doesn't show how.

This post is similar but there's no answer because for that case there's no other calls on hold hence there's no requirement to bring CallKit to the front: CallKit - How to bring the CXCallController to the front

2

There are 2 best solutions below

0
On BEST ANSWER

I found that the info that I got on stackoverflow on this topic were outdated. For the case where there's multiple calls on CallKit, the green bar will show even when your app is in the foreground given that your app is showing the status bar!

Previously it didn't appear on my app because I have set the status bar to be hidden on that particular page where the call is being made... so the solution is to detect when there is call being set to on hold (via callkit delegate) and show the status bar, and hide it when one of the calls ended and there's no more calls on hold.

When user clicks on the green bar while inside your app, it brings user back to the CallKit UI as expected.

0
On

First declare variables

  • var callKitProvider: CXProvider!

  • var udid = UUID()

then call this function where call will be ended

callKitProvider.reportCall(with: udid, endedAt: Date(), reason: .remoteEnded)

please make sure that same udid used in "report call" and "incoming call"