How to keep native UI after accept a call using Callkit
Asked Answered
P

1

12

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())

}
Phenacite answered 3/3, 2017 at 16:27 Comment(1)
do your calling screen UI speaker become active when after call being received ?Joerg
A
22

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.

Accompany answered 6/3, 2017 at 8:23 Comment(6)
great answer. Do you know what happened when you accept a call from the locked screen?Langston
the didActivate method does not seem to get called.Langston
I haven't found any new settings in iOS 11 that let you use use the native Phone UI sadly.Revival
I know... It was a bad notice when I was checking Callkit changes in iOS 11.Accompany
do your calling screen UI speaker become active when after call being received ?Joerg
@AbhishekMitra Yes, you need to disable it.Accompany

© 2022 - 2024 — McMap. All rights reserved.