2

我浏览了 iOS CallKit文档,以下是 Apple 在“拨打电话”部分提供的代码。当我尝试调用函数startOutGoingCall()时,没有任何反应,即我看不到任何拨出呼叫 UI。

有人可以建议我如何触发本机拨出电话 UI。

func startOutGoingCall(){
    let uuid = UUID()
    let handle = CXHandle(type: .emailAddress, value: "jappleseed@apple.com")

    let startCallAction = CXStartCallAction(call: uuid)
    startCallAction.destination = handle

    let transaction = CXTransaction(action: startCallAction)
    callController.request(transaction) { error in
        if let error = error {
            print("Error requesting transaction: \(error)")
        } else {
            print("Requested transaction successfully")
        }
    }
}

编辑:从我的代码中添加了委托方法

func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
        logMessage(messageText: "provider:performStartCallAction:")

        /*
         * Configure the audio session, but do not start call audio here, since it must be done once
         * the audio session has been activated by the system after having its priority elevated.
         */
        localMedia?.audioController.configureAudioSession(.videoChatSpeaker)

        callKitProvider.reportOutgoingCall(with: action.callUUID, startedConnectingAt: nil)

        performRoomConnect(uuid: action.callUUID, roomName: action.handle.value) { (success) in
            if (success) {
                provider.reportOutgoingCall(with: action.callUUID, connectedAt: Date())
                action.fulfill()
            } else {
                action.fail()
            }
        }
    }
4

1 回答 1

9

CallKit 没有传出用户界面。当您拨出电话时,您的应用程序处于打开状态,因此应该由您的应用程序显示 UI。

于 2017-01-07T16:37:36.670 回答