Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS中的Twilio语音呼叫问题_Ios_Swift_Twilio - Fatal编程技术网

iOS中的Twilio语音呼叫问题

iOS中的Twilio语音呼叫问题,ios,swift,twilio,Ios,Swift,Twilio,我正在做twilio Voip电话。我遵循了twilio的文档,并根据文档下载了该项目,遵循了该项目的说明,并根据php中的我的更改了基本url。现在我正在拿代币。我正在将该令牌传递给delegates方法,但调用无法连接。我还启用了来自功能的音频调用。但它仍然不起作用。这是我的twilio语音通话代码 func callFetchVoiceTokenAPI() { let param = [ "token" : LoginToken!, "identi

我正在做twilio Voip电话。我遵循了twilio的文档,并根据文档下载了该项目,遵循了该项目的说明,并根据php中的我的更改了基本url。现在我正在拿代币。我正在将该令牌传递给delegates方法,但调用无法连接。我还启用了来自功能的音频调用。但它仍然不起作用。这是我的twilio语音通话代码

func callFetchVoiceTokenAPI() {

    let param = [
        "token" : LoginToken!,
        "identity" : myPhoneNumber!
    ] as [String : Any]

    ServerCall.makeCallWitoutFile(fetchVoiceTokenUrl, params: param, type: Method.POST, currentView: self.view) { (response) in

        print(response ?? JSON.null)

        if let json = response {
            if !json.isEmpty {

                let token = json["token"].stringValue
                print(token)
                let success = json["success"].boolValue
                print(success)
                self.placeCall()
               UserDefaults.standard.set(token, forKey: "voiceToken")
               UserDefaults.standard.synchronize()
            }
        }
    }
}
func placeCall(){

    if (self.call != nil && self.call?.state == .connected) {
        self.call?.disconnect()
       // self.toggleUIState(isEnabled: false, showCallControl: false)
    } else {
        let uuid = UUID()
        let handle = "Hello Hamza"
        print(uuid)
        performStartCallAction(uuid: uuid, handle: handle)
    }

}
 // MARK: Call Kit Actions
func performStartCallAction(uuid: UUID, handle: String) {
    let callHandle = CXHandle(type: .generic, value: handle)
    let startCallAction = CXStartCallAction(call: uuid, handle: callHandle)
    let transaction = CXTransaction(action: startCallAction)
    print(callHandle,startCallAction,transaction)
    callKitCallController.request(transaction)  { error in
        if let error = error {
            NSLog("StartCallAction transaction request failed: \(error.localizedDescription)")
            return
        }

        NSLog("StartCallAction transaction request successful")

        let callUpdate = CXCallUpdate()
        callUpdate.remoteHandle = callHandle
        callUpdate.supportsDTMF = true
        callUpdate.supportsHolding = true
        callUpdate.supportsGrouping = false
        callUpdate.supportsUngrouping = false
        callUpdate.hasVideo = false

        self.callKitProvider.reportCall(with: uuid, updated: callUpdate)
    }
}
func performVoiceCall(uuid: UUID, client: String?, completionHandler: @escaping (Bool) -> Swift.Void) {
    let accessToken = UserDefaults.standard.string(forKey: "voiceToken")
    if accessToken != nil  {
        print(accessToken!)
    }else {
        completionHandler(false)
        return
    }

    call = TwilioVoice.call(accessToken!, params: [twimlParamTo : twimlParamTo], uuid:uuid, delegate: self)
    print(call!)
    self.callKitCompletionCallback = completionHandler
}
这就是所有代码执行时的结果,

当你说“它不工作”时,你的确切意思是什么?屏幕截图似乎表明呼叫已启动,但看起来像是来电。您是否在应用程序、中或电话中收到错误消息?仅显示此屏幕,之前未显示任何内容。它是否在模拟器中工作?