tencent cloud


Last updated: 2024-01-18 11:32:46
    This document describes how to quickly integrate the TUICallKit component. Performing the following key steps generally takes about an hour, after which you can implement the video call feature with complete UIs.

    Environment Preparations

    iOS 9.0 (API level 16) or later.

    Step 1. Activate the service

    TUICallKit is a video calling component built on top of Tencent Cloud's Instant Messaging (IM) and Real-Time Communication (TRTC) paid PaaS services. You can follow the steps below to activate the relevant services and experience a 7-day free trial.
    1. Log in to the TRTC Console, click on "Create application". In the pop-up window, select the "Call", enter the application name, and click "Create".
    2. After completing the application creation, you will be directed to the application details page. In the pop-up window, select the "Free Trial" version and click on "Get started for free".
    3. After confirming the pop-up content, click on "Free Trail" to successfully open the trial version of audio and video calling.
    4. After completing the application creation, you will be redirected to the application details page. The SDKAppID and SDKSecretKey obtained here will be used for Log in to the TUICallKit component.

    Step 2. Import the component

    Use CocoaPods to import the component as follows:
    1. Add the following dependency to your Podfile.
    pod 'TUICallKit'
    2. Run the following command to install the component:
    pod install
    If the latest version of TUICallKit cannot be installed, run the following command to update the local CocoaPods repository list:
    pod repo update
    Afterwards, execute the following command to update the Pod version of the component library.
    pod update

    Step 3. Configure the project

    Your app needs mic and camera permissions to implement audio/video communication. Add the two items below to Info.plist of your app. Their content is what users see in the mic and camera access pop-up windows.
    <string>CallingApp needs to access your camera to capture video.</string>
    <string>CallingApp needs to access your mic to capture audio.</string>

    Step 4. Log in to the TUICallKit component

    Add the following code to your project to call the relevant APIs in TUICore to log in to the TUICallKit component. This step is very important, as the user can use the component features properly only after a successful login. Carefully check whether the relevant parameters are correctly configured:
    #import <TUICore/TUILogin.h>
    // Log in to the component
    [TUILogin login:1400000001 // Replace it with the `SDKAppID` obtained in step 1.
    userID:@"denny" // Replace it with your `UserID`.
    userSig:@"xxxxxxxxxxx" // You can calculate a `UserSig` in the console and enter it here.
    NSLog(@"login success");
    } fail:^(int code, NSString *msg) {
    NSLog(@"login failed, code: %d, error: %@", code, msg);
    import TUICore
    // Log in to the component
    TUILogin.login(1400000001, // Replace it with the `SDKAppID` obtained in step 1.
    userID: "denny", // Replace it with your `UserID`.
    userSig: "xxxxxxxxxxx") { // You can calculate a `UserSig` in the console and enter it here.
    print("login success")
    } fail: { (code, message) in
    print("login failed, code: \\(code), error: \\(message ?? "nil")")
    Parameter description: The key parameters used by the login function are as detailed below:
    SDKAppID: Obtained in the last step in step 1 and not detailed here.
    UserID: The ID of the current user, which is a string that can contain only letters (a–z and A–Z), digits (0–9), hyphens (-), or underscores (_).
    UserSig: The authentication credential used by Tencent Cloud to verify whether the current user is allowed to use the TRTC service. You can get it by using the SDKSecretKey to encrypt the information such as SDKAppID and UserID. You can generate a temporary UserSig by clicking the UserSig Generate button in the console.
    For more information, see UserSig.
    Many developers have contacted us with many questions regarding this step. Below are some of the frequently encountered problems:
    SDKAppID is invalid.
    userSig is set to the value of Secretkey mistakenly. The userSig is generated by using the SecretKey for the purpose of encrypting information such as sdkAppId, userId, and the expiration time. But the value of the userSig that is required cannot be directly substituted with the value of the SecretKey.
    userId is set to a simple string such as 1, 123, or 111, and your colleague may be using the same userId while working on a project simultaneously. In this case, login will fail as TRTC doesn't support login on multiple terminals with the same UserID. Therefore, we recommend you use some distinguishable userId values during debugging.
    The sample code on GitHub uses the genTestUserSig function to calculate UserSig locally, so as to help you complete the current integration process more quickly. However, this scheme exposes your SecretKey in the application code, which makes it difficult for you to upgrade and protect your SecretKey subsequently. Therefore, we strongly recommend you run the UserSig calculation logic on the server and make the application request the UserSig calculated in real time every time the application uses the TUICallKit component from the server.

    Step 5. Make a call

    One-to-one video call

    You can call the call function of TUICallKit and specify the call type and the callee's userId to make an audio/video call.
    #import <TUICallKit/TUICallKit.h>
    // Make a one-to-one video call. Suppose the `userId` is `mike`.
    [[TUICallKit createInstance] call:@"mike" callMediaType:TUICallMediaTypeVideo];
    import TUICallKit
    // Make a one-to-one video call. Suppose the `userId` is `mike`.
    TUICallKit.createInstance().call(userId: "mike", callMediaType: .video)
    The ID of the target user, such as "mike".
    The call media type, such as TUICallMediaTypeVideo.

    Group video call

    You can call the groupCall function of TUICallKit and specify the call type and the list of callees' UserID values to make a group audio/video call.
    #import <TUICallKit/TUICallKit.h>
    [[TUICallKit createInstance] groupCall:@"12345678" userIdList:@[@"denny", @"mike", @"tommy"] callMediaType:TUICallMediaTypeVideo];
    import TUICallKit
    TUICallKit.createInstance().groupCall(groupId: "12345678", userIdList: ["denny", "mike", "tommy"], callMediaType: .video)
    The group ID, such as @"12345678".
    The list of userId values of the target users, such as @[@"denny", @"mike", @"tommy"].
    The call media type, such as TUICallMediaTypeVideo.
    You can create a group as instructed in Android, iOS, and macOS. You can also use Chat TUIKit to integrate chat and call scenarios at one stop.
    TUICallKit currently doesn't support making a group video call among users not in a group. If you have such a need, please contact colleenyu@tencent.com.

    Step 6. Answer a call

    After step 4, when receiving an incoming call, the TUICallKit component will automatically display the call answering UI.

    Step 7. Implement more features

    1. Nickname and profile photo settings

    To customize the nickname or profile photo, use the following API for update:
    [[TUICallKit createInstance] setSelfInfo:@"nickname" avatar:@"profile photo URL" succ:^{
    } fail:^(int code, NSString *errMsg) {
    TUICallKit.createInstance().setSelfInfo(nickname: "nickname", avatar: "profile photo URL", succ: {
    }) { code, desc in
    The update of the callee's nickname and profile photo may be delayed during a call between non-friend users due to the user privacy settings. After a call is made successfully, the information will also be updated properly in subsequent calls.

    2. Offline call push

    You can make/answer audio or video calls after completing the above steps. However, if you want your users to be able to receive call invitations even when your application is in the background or after it is closed, then you need to also implement the offline call push feature. For more information, see Offline Call Push (iOS).

    3. Floating window

    To implement the floating window feature in your application, call the following API when initializing the TUICallKit component:
    [[TUICallKit createInstance] enableFloatWindow:YES];

    4. Listening on the call status

    To listen on the call status (for example, the start or end of a call or the call quality during a call), listen on the following events:
    #import <TUICallEngine/TUICallEngine.h>
    [[TUICallEngine createInstance] addObserver:self];
    - (void)onCallBegin:(TUIRoomId *)roomId callMediaType:(TUICallMediaType)callMediaType callRole:(TUICallRole)callRole {
    - (void)onCallEnd:(TUIRoomId *)roomId callMediaType:(TUICallMediaType)callMediaType callRole:(TUICallRole)callRole totalTime:(float)totalTime {
    - (void)onUserNetworkQualityChanged:(NSArray<TUINetworkQualityInfo *> *)networkQualityList {
    import TUICallEngine
    public func onCallBegin(roomId: TUIRoomId, callMediaType: TUICallMediaType, callRole: TUICallRole) {
    public func onCallEnd(roomId: TUIRoomId, callMediaType: TUICallMediaType, callRole: TUICallRole, totalTime: Float) {
    public func onUserNetworkQualityChanged(networkQualityList: [TUINetworkQualityInfo]) {

    5. Custom ringtone

    You can use the following API to customize the ringtone:
    [[TUICallKit createInstance] setCallingBell:filePath];
    TUICallKit.createInstance().setCallingBell(filePath: filePath)

    6. Custom call timeout period

    You can set callParams when invoke call, groupCall,inviteUser to change your call timeout period.
    TUICallParams *callParams = [TUICallParams new];
    callParams.offlinePushInfo = [TUIOfflinePushInfo new];
    callParams.timeout = 30;
    callParams.userData = @"user data";
    [[TUICallKit createInstance] call:@"mike" callMediaType:TUICallMediaTypeVideo params:callParams succ:nil fail:nil];
    let callParams = TUICallParams()
    let offlinePushInfo = TUIOfflinePushInfo()
    callParams.offlinePushInfo = offlinePushInfo
    callParams.timeout = 30
    callParams.userData = "user data"
    TUICallKit.createInstance().call(userId: "mike", callMediaType: .video, params: callParams) {



    1. What should I do if I receive the error message "The package you purchased does not support this ability"?

    The error message indicates that your application's audio/video call capability package has expired or is not activated. You can claim or activate the audio/video call capability as instructed in step 1 to continue using TUICallKit.

    2. How to purchase official version?

    please refer to Purchase Official Version.

    Suggestions and Feedback

    If you have any suggestions or feedback, please contact colleenyu@tencent.com.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support