Integrating Video Calling (IOS)

Last updated: 2020-09-09 14:48:49

    TUIKit 4.8.50 and later versions provide video and voice call features for one-to-one and group chats based on TRTC and support interconnection between iOS and Android platforms. To quickly integrate TUIKit video and voice call features, follow the steps described in this document.

    Note:

    • In TUIKit 4.8.50 and later versions, the voice and video call features are integrated in the TUIKit component and designed based on the new signaling solution.
    • In versions earlier than TUIKit 4.8.50, the voice and video call features are integrated in the TUIKitDemo sample on the iOS client. If you use the voice and video call features of an earlier version, we do not recommend that you upgrade the version to avoid compatibility issues.

    Step 1: Enable the TRTC Service

    1. Log in to the IM console and click the target application card to go to the basic configuration page of the application.
    2. Click Activate in the Tencent Real-Time Communication (TRTC) area.
    3. In the dialog box that appears, click OK.
      The system will create a TRTC application with the same SDKAppID as the current IM application in the TRTC console. You can use the same account and authentication information for the two applications.

    Step 2: Configure the Engineering File

    1. Add the following content to the podfile file.

      // Only TUIKit 4.8.50 and later versions support the voice and video call features.
      pod 'TXIMSDK_TUIKit_iOS'                 // By default, the audio and video library of the TXLiteAVSDK_TRTC version is integrated.
      // pod 'TXIMSDK_TUIKit_iOS_Professional' // By default, the audio and video library of the TXLiteAVSDK_Professional version is integrated.

      You cannot integrate different Tencent Cloud audio and video libraries at the same time as this will cause symbol conflicts. If you use a library not of the TRTC version, we recommend that you remove it and integrate the TXIMSDK_TUIKit_iOS_Professional version. The audio and video library of the LiteAV_Professional version contains all basic audio and video capabilities.

    2. Run the following command to download the third-party library to the current project:

      pod install

      If you cannot install the latest TUIKit version, run the following command to update the local CocoaPods repository list:

      pod repo update

    Step 3: Initialize TUIKit

    To initialize TUIKit, enter the SDKAppID generated in Step 1.

    [[TUIKit sharedInstance] setupWithAppId:SDKAppID];

    Step 4: Log In to TUIKit

    Call the login API provided by TUIKit to log in to IM. For more information on how to generate UserSig, see How to Generate Usersig.

    [[TUIKit sharedInstance] login:@"userID" userSig:@"userSig" succ:^{
         NSLog(@"-----> Login successful");
    } fail:^(int code, NSString *msg) {
         NSLog(@"-----> Login failed");
    }];

    Step 5: Initiate a Video or Voice Call

    When you tap Video or Voice on the chat UI, TUIKit displays the call invitation UI and sends a call request to the peer.

    Step 6: Answer a Video or Voice Call

    • When an online user receives a call invitation, TUIKit displays the call accept UI. The user can answer or reject the call.
    • When an offline user receives a call invitation, offline push is required to wake up the app call UI. For more information about offline push, see Step 7.

    Step 7: Offline Push

    To implement offline push for voice and video calls, follow these steps:

    1. Configure offline push for the app. For more information, see Offline Push Configuration.
    2. Upgrade TUIKit to 4.9.1 or later.
    3. Use TUIKit to initiate a call invitation. An offline push message will be generated by default. For more information about the message generation logic, see the sendAPNsForCall function in the TUICall+Signal.m class.
    4. After the peer receives the offline push message, the peer can call the didReceiveRemoteNotification callback in the AppDelegate source code to wake up the call UI.

    FAQs

    1. What should I be aware of if I have created the TRTC and IM SDKAppIDs and want to integrate the IM SDK and TRTC SDK at the same time?

    If you have created the TRTC and IM SDKAppIDs, you cannot use the same account or authentication information for these two applications. You need to generate a UserSig corresponding to the TRTC SDKAppID to perform authentication. For more information on how to generate UserSig, see How to Generate Usersig.

    After obtaining the TRTC SDKAppID and UserSig, modify the following code in the TRTCCall+Room.swift source code:

     func enterRoom() {
         let param = TRTCParams()
         // TRTC SDKAppID
         param.sdkAppId = 1000000000 
         // UserSig generated based on the TRTC SDKAppID
         param.userSig = "userSig"
      }

    2. How long is the default call invitation timeout time? How can I modify the default timeout time?

    The default call invitation timeout time is 30s. You can modify the timeOut field in TRTCCall.swift to customize the timeout time.

    3. Will an invitee receive a call invitation if the invitee goes offline and then online within the call invitation timeout time?

    • If the call invitation is initiated in a one-to-one chat, the invitee can receive the call invitation.
    • If the call invitation is initiated in a group chat, the invitee cannot receive the call invitation.

    4. What can I do if TUIkit conflicts with the integrated audio and video library?

    You cannot integrate different Tencent Cloud audio and video libraries at the same time as this will cause symbol conflicts. If you use a library not of the TRTC version, we recommend that you remove it and integrate the TXIMSDK_TUIKit_iOS_Professional version. The audio and video library of the LiteAV_Professional version contains all basic audio and video capabilities.
    If you use a LiteAV_Enterprise audio and video library, it cannot coexist with TUIKit.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help