I have integrated a video call with voice call in sinch on swift project. But the problem is , in the appDelegate
I have a function didReceiveIncomingCall
. How can I put some code inside this function to determine if the call is voice call to show voiceCallVC
or if the call is videoCall to show VideoVC
.
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)
}
You can check For the Bool value 'call.details.isVideoOffered'
Here is the Code For This
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)
}
}