-
Notifications
You must be signed in to change notification settings - Fork 0
Channelize Voice And Video SDK Documentation
rohitphogat19 edited this page Jun 20, 2019
·
9 revisions
If you are Using both API and UI SDK, then it is Already integrated in UI SDK. You can enable or Disable this feature in UI SDK customization by using below code
CHCustomOptions.enableVoiceVideo = true // TRUE => Enabled , FALSE => DisabledIf you are not using Channelize UI SDK, to make a outgoing call follow below procedure
You have to create a CHActiveCall object by calling below method
/*
Parameters Required
1. user : Type => CHUser, Required => Yes, Description => User with whom you are making Call
2. type : Type => CallScreen, Required => Yes, Description => Type of call, Possible Values => .voice or .video
*/
let userObject : CHUser = currentConversationUser
let callType : CallScreen = .video
let callObject = ChVoiceVideo.getCallObject(user: userObject, type: callType)After creating call object, call below method to start a outgoing Call
/*
Parameters Required
1. navigationContoller : Type => UINavigationController, Required => Yes
2. activeCall : Type => CHActiveCall, Required => Yes, Description => call Object Created above
*/
ChVoiceVideo.launchCallViewController(navigationController: UINAVIGATIONCONTROLLER,activeCall:CALL_OBJECT)To handle incoming call, Channelize is using Pushkit and Callkit frameworks. To Handle incoming call open your AppDelegate.swift file, import Pushkit framework and confirm AppDelegate class to PKPushRegistryDelegate protocols and paste following code:
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
let deviceToken = pushCredentials.token.reduce("", {$0 + String(format: "%02X", $1) })
debugPrint("Token recieved - ",deviceToken)
debugPrint("Device Id - ",UIDevice.current.identifierForVendor!.uuidString)
//VSDK Changes
Channelize.updateVoipToken(token: deviceToken)
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
print("VOIP Notification Recieved")
print("PayLoad Dictionary is \(payload.dictionaryPayload)")
if let callId = payload.dictionaryPayload["callId"] as? String{
if let uid = payload.dictionaryPayload["userId"] as? String{
if let uuidString = payload.dictionaryPayload["uuid"] as? String{
if let uuid = UUID(uuidString: uuidString){
let call = CHActiveCall(uuid: uuid, callId: callId, uid: uid, isOutgoing: false)
call.displayName = payload.dictionaryPayload["displayName"] as? String
call.profileImageUrl = payload.dictionaryPayload["profileImageUrl"] as? String
if let callType = payload.dictionaryPayload["type"] as? String{
if callType == "video"{
call.type = .video
}
}
let backgroundTaskIdentifier = UIApplication.shared.beginBackgroundTask(expirationHandler: nil)
if CHCustomOptions.enableCallModule{
let bundleUrl = Bundle.url(forResource: "Channelize_Voice_Video", withExtension: "framework", subdirectory: "Frameworks", in: Bundle.main.bundleURL)
let bundle = Bundle(url: bundleUrl!)
bundle?.load()
let aClass : AnyClass? = NSClassFromString("Channelize_Voice_Video.ChVoiceVideo")
if let callMainClass = aClass as? CallSDKDelegates.Type{
print("Incoming Call Step 1 -> VOIP Recieved")
callMainClass.showIncomingCall(call: call, completion: {_ in
UIApplication.shared.endBackgroundTask(backgroundTaskIdentifier)
})
}
}
}
}
}
}
}
func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
print("\(#function) token invalidated")
}