-
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.
- Create a variable for push registry
let pushRegistry = PKPushRegistry(queue: DispatchQueue.main)2.In didFinishLaunchingWithOptions method paste following code
pushRegistry.delegate = self
pushRegistry.desiredPushTypes = [.voIP]- Confirm
AppDelegateclass toPKPushRegistryDelegateprotocols 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)
Channelize.updateVoipToken(token: deviceToken)
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
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{
ChVoiceVideo.showIncomingCall(call: call, completion: {_ in
UIApplication.shared.endBackgroundTask(backgroundTaskIdentifier)
})
}
}
}
}
}
}
func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
print("\(#function) token invalidated")
}