使用CallKit和Twilio-Video API触发传入的VoIP呼叫 [英] Trigger an incoming VoIP call using CallKit and Twilio-Video API

查看:604
本文介绍了使用CallKit和Twilio-Video API触发传入的VoIP呼叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Twilio提供的示例视频通话应用程序之一( VideoCallKitQuickStart ) ,我试图通过向应用程序发送VoIP通知来触发来电。但该应用程序不会触发来电。我还尝试在发送VoIP通知时保持应用程序打开并且应用程序崩溃,抛出以下异常

By using one of the sample video calling app provided by Twilio (VideoCallKitQuickStart), I am trying to trigger an incoming call by sending a VoIP notification to the App. But the App doesn't trigger an incoming call. I also tried keeping the App opened while sending a VoIP notification and the App crashes, by throwing the below exception


NSInvalidArgumentException:尝试
插入非属性列表对象'PKPushPayload:0x16e44af0'用于键
有效载荷

NSInvalidArgumentException: Attempt to insert non-property list object 'PKPushPayload: 0x16e44af0' for key payload

有人可以帮助我或者当收到VoIP通知时,我指出了如何在App中触发来电的正确方向。

Could someone, please help me or point me in the right direction on how to trigger an incoming call in the App, when a VoIP notification is received.

以下是我在ViewController.swift文件中的代码

Below is my code in the ViewController.swift file

 func pushRegistry(registry: PKPushRegistry!, didReceiveIncomingPushWithPayload payload: PKPushPayload!, forType type: String!) {
        // Process the received push

        self.reportIncomingCall(uuid: UUID(), roomName: "testRoom", completion: nil)
    } 

func reportIncomingCall(uuid: UUID, roomName: String?, completion: ((NSError?) -> Void)? = nil) {

    let callHandle = CXHandle(type: .generic, value: roomName ?? "")
    let callUpdate = CXCallUpdate()
    callUpdate.remoteHandle = callHandle
    callUpdate.supportsDTMF = false
    callUpdate.supportsHolding = true
    callUpdate.supportsGrouping = false
    callUpdate.supportsUngrouping = false
    callUpdate.hasVideo = true

    callKitProvider.reportNewIncomingCall(with: uuid, update: callUpdate) { error in
        if error == nil {
            NSLog("Incoming call successfully reported.")
        } else {
            NSLog("Failed to report incoming call successfully: \(error?.localizedDescription).")
        }
        completion?(error as? NSError)
    }
}


推荐答案

Swift 3.0

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType) {
    NSLog("pushRegistry:didReceiveIncomingPushWithPayload:forType:")

    if (type == PKPushType.voIP) {
        print(payload.dictionaryPayload)
        VoiceClient.sharedInstance().handleNotification(payload.dictionaryPayload, delegate: self)
    }
}

请不要做任何更改有效负载而不进行修改,以便SDK从有效负载中提取传入呼叫信息,以便SDK可以通过来电通知应用程序

And please don't make any changes in payload without modifying it in order for the SDK to extract the incoming call info out of the payload so that the SDK can notify the application with incoming calls

这篇关于使用CallKit和Twilio-Video API触发传入的VoIP呼叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆