簡體   English   中英

如何使用iOS Callkit模擬去電

[英]How can I simulate an Outgoing call using iOS Callkit

我已經閱讀了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()
            }
        }
    }

您沒有從CallKit獲得傳出的UI。 撥出電話時,您的應用程序處於打開狀態,因此應顯示UI。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM