Add A CallKit Entry without initiating native UI - ios

I'm having issues with presenting the correct UI when using CallKit.
I would like to be able to create a CallKit call without presenting the native UI (Accept/Reject screen). From my knowledge the only way to create a CallKit object is by using an intent (which still requires the CallKit screen) or present an incoming call screen, which after pressing Accept you have a call going.
I'm using WebRTC as the medium so I can actually "create" calls without CallKit; however when I go to homescreen after initializing calls this way I get a red bar instead of the preferred green bar.
Is there a way around the CallKit screen when creating calls?
Thanks in advance!

There's a behavioral difference between incoming and outgoing calls:
For incoming calls, the system's native incoming call UI (including the Accept and Reject buttons) is always shown, and if the call is answered while the device is unlocked, the user will be taken immediately to the app to continue the call.
For outgoing calls, the system's native call UI is not shown.

Related

How to detect non-intrusive phone call

In iOS 14 you can now accept phone calls that do not take up the entire screen (the new non-intrusive phone call UI looks like a push notification). If you accept the call, but do not open up the full screen call UI, the app remains open. This is true even if you pick up the phone and put it to your ear the app remains active.
What would the best way be to detect an incoming call, or that the user began the call?
You can’t detect it. If the user just takes the call direct from the banner, your app remains active and there is nothing to detect. That is the whole point of this feature: a call need not interrupt your app in any way.

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

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.
Start Voip call
During the call, someone calls the phone using non internet sim/phone line
CallKit UI shows up, with options to decline, end, or hold the voip call to answer the incoming phone call
Select 'hold and answer', callkit UI shows two calls, with the voip call being hold
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
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.
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
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.
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"

When to use native CallKit UI and when your own custom telephone UI?

I integrated CallKit successfully in my app, but I'm kind of confused how to use it correctly. When the phone is in locked state, I get the native Call UI like this:
When my app is in background and it receives an incoming call, the following interface I get:
By the way, after I accept the call, it opens my app and brings it to the foreground.
While I'm expecting the native Call UI (CallKit) to stay in the foreground when accepted the call.
However, if my app is brought to the foreground by CallKit, the native Call UI is not gone, but stays in memory. When I double press on the home button to get a list of opened apps, I can see the native Call UI as follows:
So the native Call UI is still there and I can get it to the foreground and control the call. So, what happens is, I get 2 UI's, one is the native Call UI and the other is my own app.
Also, the examples and demos I found about CallKit is confusing, because I only see native Call UI and no custom VoIP app UI. So what's the deal with Call UI? When should it be displayed and when should a custom app UI be displayed?
I know that it seems a bit confusing at first, but it's just the way it works. You don't have control on whether to show the system UI or your custom UI.
While the phone is ringing only the system UI is shown. As soon as you answer, if the phone is locked then the system UI is shown; if the phone is unlocked then your app will become active and your custom UI is shown.

callkit default UI for outgoing call

I use outgoing call only in the app on iOS 10.3.3. If I do not have connected headphones to iPhone then pressing on lock button will end the call. But what if I have connected headphones?
Sometimes (after lock) I see native UI. Sometimes I see just time counter without any buttons (like speaker, mute, etc). Is there any special flag (or I should implement some delegate?) to allow see native callkit screen after pressing lock button? It looks like I tried everything here...
P.S. I know this screen could be showed while user take a call while iphone locked. But I would like (and I got it several times at least) to get this screen on lock device.
Did I miss something?
I hope that is the native iOS behaviour, callkit works similar to the native calls.
So customisation can't be done on call screens in lock mode.

Speakerbox IOS callkit UI hides itself after call receive

After accepting incoming call on speakerbox iOS, the UI which shows caller name and timer on native call controller goes back of the app. Is there a way to take that to the front form where user can disconnect, mute and see the timer.
When your app is in the foreground, it is responsible for showing a UI for the call (for example, what does your app do on iOS 9?). So by bringing your app to the foreground, that is enough.

Resources