-
Notifications
You must be signed in to change notification settings - Fork 0
Channelize Voice And Video SDK Documentation
Add the following pod to the Podfile.
pod 'ChannelizeCall'
And then install the Channelize Call SDK through CocoaPods.
pod install
You need to set up account on Agora.io to get agora app key. After getting key, please add following key in your Channelize-Info.plist
file.
<key>AGORA_API_KEY</key>
<string>YOUR_AGORA_KEY</string>
Note: Where ever you want to use Channelize, please import following
import Channelize_Voice_Video
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 => Disabled
If you are not using Channelize UI SDK, follow below process to make Incoming and Outgoing call.
First create a call object by Calling getCallObject
function of Call SDK,
Name | Type | Required | Description |
---|---|---|---|
user | CHUser |
Yes |
CHUser object of user whom with you are making call |
type | CallScreen |
Yes | 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
ChVoiceVideo.launchCallViewController(navigationController: UINAVIGATIONCONTROLLER,activeCall:callObject)
To handle Incoming call,make sure Background Modes are on in your app with Voice over Ip,Background Fetch options are enabled.
Also Make sure to upload VOIP certificate .pem file and VOIP key .pem file on Channelize Dashboard for incoming call in iOS.
For 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)
In didFinishLaunchingWithOptions
method paste following code
pushRegistry.delegate = self
pushRegistry.desiredPushTypes = [.voIP]
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)
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")
}