提交工单
咨询集成、功能及报价等问题
This doc will introduce how to use In-app Chat Kit with Call Kit.
Integrate the In-app Chat Kit SDK into your project. For more information, see Quick start.
Podfile
file:pod 'ZegoUIKitPrebuiltCall'
pod install
After successfully logging in to the In-app Chat Kit, add the following code to initialize Call Kit:
let appID: UInt32 = YOUR_APPID
let appSign: String = YOUR_APP_SIGN
let userID: String = YOUR_USER_ID
let userName: String = YOUR_USER_NAME
ZIMKit.connectUser(userID: userID, userName: userName) { error in
if error.code == .success {
let config = ZegoUIKitPrebuiltCallInvitationConfig(notifyWhenAppRunningInBackgroundOrQuit: true, isSandboxEnvironment: false)
ZegoUIKitPrebuiltCallInvitationService.shared.initWithAppID(appID, appSign: appSign, userID: userID, userName: userName, config: config)
}
}
ZIMKitConversationListVC
, you can set it using the following code:let conversationVC = ZIMKitConversationListVC()
conversationVC.messageDelegate = self
ZIMKitMessagesListVC
, you can set it using the following code:let messageVC = ZIMKitMessagesListVC(conversationID: "conversationID", type: .peer)
messageVC.delegate = self
Implement the getMessageListHeaderBar
delegate and add the call button.
import ZIMKit
import ZegoUIKitPrebuiltCall
extension ViewController: ZIMKitMessagesListVCDelegate {
func getMessageListHeaderBar(_ messageListVC: ZIMKitMessagesListVC) -> ZIMKitHeaderBar? {
if messageListVC.conversationType != .peer { return nil }
// Get conversationID and conversationName from messageListVC
let conversationID = messageListVC.conversationID
let conversationName = messageListVC.conversationName
// Create voice call button and set the user to be called as ZegoUIKitUser
let voiceCallButton = ZegoSendCallInvitationButton(ZegoInvitationType.voiceCall.rawValue)
voiceCallButton.inviteeList = [ZegoUIKitUser(conversationID, conversationName)]
// Create video call button and set the user to be called as ZegoUIKitUser
let videoCallButton = ZegoSendCallInvitationButton(ZegoInvitationType.videoCall.rawValue)
videoCallButton.inviteeList = [ZegoUIKitUser(conversationID, conversationName)]
// Create UIBarButtonItem using the above buttons
let voiceItem = UIBarButtonItem(customView: voiceCallButton)
let videoItem = UIBarButtonItem(customView: videoCallButton)
// Create HeaderBar and set voice and video to `rightItems`
let header = ZIMKitHeaderBar()
header.rightItems = [videoItem, voiceItem]
return header
}
}
So far, you have successfully integrated Call Kit in the In-app Chat Kit. You can now run and experience it.
The above content only introduces the basic configuration required for integrating Call Kit. If you need to further customize the configuration of the call, refer to the following documents: