Quickstart
Channelize.io iOS Call SDK along with API SDK and UI SDK helps you achieve the complete calling and real-time messaging solution.
NOTE: Channelize.io iOS Call SDK is using Channelize.io API SDK for networking and real-time events.
Install iOS Call SDK
Step 1: Integration
Note: Please make sure you use same integration method for all SDKs.
1. Manual Integration
Install SDK
- Download the Channelize Call SDK zip file from here.
- Extract the downloaded file to a folder. It will provide
ChannelizeCall.xcframework
file. - Add it to your project in same way you have added
ChannelizeAPI
SDK.
Install Pods
Add following pods to the existing Podfile
that you had created while installing API SDK.
Note: Don't put pod 'SDWebImageFLPlugin'
if you are using UI SDK also. SDWebImageFLPlugin
is already installed
pod 'SDWebImageFLPlugin'
pod 'AgoraRtcEngine_iOS', '2.9.0'
Now run below command to install the pods after navigating to project directory through terminal
pod install --verbose
2. Through Cocoapods
Install UI Kit Pod
Add UI Kit pod to the existing Podfile
that you had created while installing API SDK.
pod 'ChannelizeCall', '>= 4.20.12'
Now run below command to install the pods after navigating to project directory through terminal
pod install --repo-update --verbose
Step 2: Create .plist file
Get you AGORA API Key by following steps mentioned here and add it to your Channelize-Info.plist
file.
<key>AGORA_API_KEY</key>
<string>YOUR_AGORA_KEY</string>
Step 3: Project Settings
Go to Xcode Project > Capabilities pane.
Add Background Modes capabilities and Push Notification capabilities if not already added in your's project. If already added you can skip this part.
Select the checkbox for Voice over IP, remote notifications and background fetch as shown in image.
Now go to Xcode Project > General pane > Frameworks, Libraries, and Embeded Content. Add Callkit Framework as shown below.
Step 4: Create Voip Certificates
To recieve incoming call, you need to upload VoIP Certificate PEM File and VoIP Key PEM File in your Channelize dashboard.
For detailed Instructions please Click here.
Step 5: Use SDK Methods
Now use all classes and methods with the import statement.
import ChannelizeCall
Integrate Call SDK using API & UI SDKs
If you are using both Channelize.io iOS API and UI SDK, then you just need to enable the call feature in UI SDK by adding below lines of code in the customizations.
CHConstants.isChannelizeCallAvailable = true // Set it true, if you want to enable call functionality otherwise set it to false.
Integrate Call SDK using API SDK
If you are not using Channelize.io UI SDK, follow the below process to make an outgoing call and handle an incoming call.
Make an Outgoing Call
Call the below method to start an outgoing call.
Name | Type | Required | Description |
---|---|---|---|
navigationController | UINavigationController | yes | Current navigation Controller of the app |
user | CHUser | yes | CHUser object of the call receiver. |
type | String | yes | The type of call you want to make. Possible values are "voice" or "video" |
CHCall.launchCallViewController(navigationController: UINAVIGATIONCONTROLLER, user: userObject, type: "video")
Receive an Incoming Call
Receive an incoming call following the below steps.
Step 1. Import Pushkit framework in AppDelegate.swift
file.
Step 2: Create a variable for push registry
let pushRegistry = PKPushRegistry(queue: DispatchQueue.main)
Step 3: In didFinishLaunchingWithOptions
method paste following code
pushRegistry.delegate = self
pushRegistry.desiredPushTypes = [.voIP]
Step 4: 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, completion: {(status,errorString) in
if status {
print("Voip Token Updated")
} else {
print("Failed to Update Voip Token with error \(errorString ?? "")")
}
})
}
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)
CHCall.showIncomingCall(call: call, completion: {_ in
UIApplication.shared.endBackgroundTask(backgroundTaskIdentifier)
})
}
}
}
}
}
func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
print("\(#function) token invalidated")
}
Configuring Channelize.io Call SDK
To configure iOS Call SDK you need to add the following code in didFinishLaunchingWithOptions
function of your project's AppDelegate.swift
file.
CHCall.configureVoiceVideo()
Xcode 11 and iOS 13 Changes
On iOS 13.0 and later, all VoIP pussh notifications be reported to the CallKit as a new call. If you fail to report a call to CallKit, the system will terminate your app. Repeatedly failing to report calls may cause the system to stop delivering any more VoIP push notifications to your app. If this occurs, the user will need to reinstall the app to get VoIP push notifications again.
Earlier, Channelize use VoIP notifications to handle call related functions like invite, end, reject, recieved and accept. Due to Apple's new guidelines, we are now using VoIP for only invite call action, which will reported as a call to Callkit. For other actions, we are now using Silent Push Notifications.
Configure App for Silent Push Notifications
Make sure you have implemented basic Push Notifications functionality mentioned here Push Notifications
After that, in func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
function in your AppDelegate
file, put below code
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if (userInfo["callId"] as? String) != nil {
CHCall.processCallActionNotification(userInfo: userInfo)
}
// Put your logic if you are already using Silent Push Notifications.
}