ios – 如何在使用Callkit接受呼叫后保留本机UI

我正在使用Callkit和Linphone开发iOS voip应用程序.当我收到来电时,系统显示本机电话用户界面,用户接受或拒绝接听电话,当用户点按接听按钮时,呼叫开始但电话用户界面消失.

如何在用户接听电话后保留本机手机用户界面,例如whatsapp吗?

此外,如何在开始拨出电话时显示本机电话用户界面?

这是我的providerDelegate代码

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"),userInfo: ["uuid":action.uuid])

    // ACCEPT CALL ON SIP MANAGER
    if let voiceCallManager = AppDelegate.voiceCallManager {
        voiceCallManager.acceptCall()
    }

    action.fulfill(withDateConnected: Date())

}

解决方法

接受来电后,您无法保留原生用户界面. Whatsapp使用自己的UI,类似于原生UI.

当您锁定iPhone并且接受来电时,它将不会向您显示APP UI.但是,如果iPhone解锁并且您接受来电,iPhone将打开您的应用,您必须显示您的手机用户界面.

对于拨打电话,您无法显示本机电话用户界面,如果您接到电话,则会显示.

因此,您需要一个用于拨出和已建立呼叫的自定义电话UI.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...