How to keep native UI after accept a call using Callkit
我正在使用Callkit和Linphone开发iOS voip应用程序。当我收到来电时,系统会显示本机电话用户界面,以供用户接受或拒绝呼叫,而当用户点击接受按钮时,呼叫将开始,但电话用户界面将消失。
在用户接受呼叫后,如whatsapp一样,如何保持本机电话UI?
此外,我如何在打出电话时显示本机电话UI?
这是我的提供者代表代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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将打开您的应用程序,并且您必须显示手机UI。
对于拨出电话,您无法显示本机电话UI,它将在您接听电话时显示。
因此,您需要用于拨出和已建立呼叫的自定义电话UI。