Sinch iOS应用程序:确定该应用程序是否收到视频或语音呼叫

时间:2018-06-28 06:35:55

标签: ios swift sinch

我在快速项目中将视频通话与语音通话集成在一起。但是问题是,在appDelegate中,我有一个函数didReceiveIncomingCall。如何在此函数中放置一些代码,以确定该呼叫是显示voiceCallVC的语音呼叫还是该呼叫是显示VideoVC的videoCall。

  func client(_ client: SINCallClient!, didReceiveIncomingCall call: SINCall!) {


        var top = self.window?.rootViewController

        while (top?.presentedViewController != nil) {
            top = top?.presentedViewController
        }

        let videoVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "videoVC") as! VideoCallVC
        videoVC._call = call
        top?.present(videoVC, animated: true, completion: nil)

        let callVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "CallVC") as! VoiceCallVC
        callVC._call = call
        top?.present(callVC, animated: true, completion: nil)
    }

1 个答案:

答案 0 :(得分:1)

您可以检查For Bool值'call.details.isVideoOffered'

这是此代码

    func client(_ client: SINCallClient!, didReceiveIncomingCall call: SINCall!) {

     var top = self.window?.rootViewController

     while (top?.presentedViewController != nil) {
        top = top?.presentedViewController
       }
        if (call.details.isVideoOffered)
        {
            let videoVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "videoVC") as! VideoCallVC
            videoVC._call = call
            top?.present(videoVC, animated: true, completion: nil)
        }
        else{
            let callVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "CallVC") as! VoiceCallVC
           callVC._call = call
           top?.present(callVC, animated: true, completion: nil)
        }

  }