I'm developing an iOS voip app using Callkit and Linphone. When I receive a incoming call, system shows the native phone UI to user accept or decline de call, whe the user taps accept button the call starts but de phone UI dissapear.
How can I keep native phone UI after user accept the call, like whatsapp do?
Also, how can I show the native phone UI when start a outgoing call?
Here's my providerDelegate code:
func reportIncomingCall(uuid: UUID, handle: String, hasVideo: Bool = false, completion: ((NSError?) -> Void)? = nil) {
// Construct a CXCallUpdate describing the incoming call, including the caller.
let update = CXCallUpdate()
update.remoteHandle = CXHandle(type: .generic, value: handle)
update.hasVideo = hasVideo
// Report the incoming call to the system
provider.reportNewIncomingCall(with: uuid, update: update) { error in
/*
Only add incoming call to the app's list of calls if the call was allowed (i.e. there was no error)
since calls may be "denied" for various legitimate reasons. See CXErrorCodeIncomingCallError.
*/
if error == nil {
print("calling")
}
}
}
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
let update = CXCallUpdate()
update.remoteHandle = action.handle
provider.reportOutgoingCall(with: action.uuid, startedConnectingAt: Date())
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "callStart"), object: self, userInfo: ["uuid":action.uuid])
action.fulfill(withDateStarted: Date())
}
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "callStart"), object: self, userInfo: ["uuid":action.uuid])
// ACCEPT CALL ON SIP MANAGER
if let voiceCallManager = AppDelegate.voiceCallManager {
voiceCallManager.acceptCall()
}
action.fulfill(withDateConnected: Date())
}
This feature is available only on Android. Tell ConnectionService that the device is ready to make outgoing calls via the native Phone app. If not the user will be stuck in the build UI screen without any actions. Eg: Call it with false when disconnected from the sip client, when your token expires, when your user log out ...
The identifier is displayed in the native call UI, and is typically the name of the call recipient. Use this to update the display after an outgoing call has started. When finish an incoming/outgoing call. (When user actively chooses to end the call from your app's UI.) End all ongoing calls. When you reject an incoming call.
The key functions here to get only the incoming call UI working is the RNCallKeep.displayIncomingCall and RNCallKeep.endCall. After my initial experiments with callkeep it seemed that IOS worked fine out of the box, however, there were some difficulties to get the same functionality working for android.
On android, native code was written so that answering the app from the lockscreen would start the react native app and navigate you to the correct screen. After these adjustments the React Native callkeep library ended up being a great fit for this project, performing all the required functionality.
You can't keep native UI after accept the incoming call. And Whatsapp use their own UI, that is similar to native UI.
When you have iPhone locked and you accept an incoming call it won't show you APP UI. But if iPhone is unlocked and you accept an incoming call iPhone will open your app, and you must show your phone UI.
And for outgoing calls you can't show native phone UI, it will show if you receive an call.
Therefor, you need a custom phone UI for outgoing and established calls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With