gpt4 book ai didi

ios - 如何在使用 Callkit 接听电话后保留 native UI

转载 作者:IT王子 更新时间:2023-10-29 05:35:44 24 4
gpt4 key购买 nike

我正在使用 Callkit 和 Linphone 开发一个 iOS 网络电话应用程序。当我接到来电时,系统会向用户显示 native 电话 UI 以接受或拒绝通话,当用户点击接受按钮时,通话开始但电话 UI 消失。

如何在用户接听电话后保留原生手机用户界面,就像 whatsapp 一样?

另外,如何在开始拨出电话时显示 native 电话 UI?

这是我的 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"), object: self, userInfo: ["uuid":action.uuid])

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

action.fulfill(withDateConnected: Date())

}

最佳答案

接听来电后无法保留原生UI。 Whatsapp 使用自己的 UI,类似于原生 UI。

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

对于拨出电话,您无法显示 native 电话 UI,如果您接到电话,它会显示。

因此,您需要一个自定义电话 UI 来拨出和建立电话。

关于ios - 如何在使用 Callkit 接听电话后保留 native UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42583903/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com