Last updated: 2021-07-05 17:40:36


    To quickly implement the audio call feature, you can directly modify the demo provided by TRTC for adaptation or use the provided TRTCCalling component and implement custom UI.


    We previously provided the TRTCAudioCall component, which has been moved to the component repository. The TRTCCalling component uses IM signaling APIs and is not compatible with the old component.

    Using Demo UI

    Step 1. Create an application

    1. Log in to the TRTC console and select Development Assistance > Demo Quick Run.
    2. Enter an application name, e.g., TestAudioCall, and click Create.

    This feature uses two basic PaaS services of Tencent Cloud, namely TRTC and IM. When you activate TRTC, IM will be activated automatically. IM is a value-added service. See Value-added Service Pricing for its billing details.

    Step 2. Download the SDK and demo source code

    1. Download the SDK and demo source code for your platform.
    2. Click Next.

    Step 3. Configure demo project files

    1. In the Modify Configuration step, select the platform in line with the source package downloaded.

    2. Find and open the iOS/TRTCScenesDemo/TXLiteAVDemo/Debug/GenerateTestUserSig.h file.

    3. Set parameters in GenerateTestUserSig.h as follows.

      • SDKAPPID: 0 by default. Set it to the actual `SDKAppID`.
      • SECRETKEY: left empty by default. Set it to the actual key.
    4. Click Next to complete the creation.

    5. After compilation, click Return to Overview Page.


    • The method for generating UserSig described in this document involves configuring SECRETKEY in client code. In this method, SECRETKEY may be easily decompiled and reversed, and if your key is leaked, attackers can steal your Tencent Cloud traffic. Therefore, this method is only suitable for the local execution and debugging of the demo.
    • The correct UserSig distribution method is to integrate the calculation code of UserSig into your server and provide an application-oriented API. When UserSig is needed, your application can send a request to the business server for a dynamic UserSig. For more information, please see How do I calculate UserSig on the server?.

    Step 4. Run the demo

    Use Xcode (version 11.0 or above) to open the iOS/TRTCScenesDemo/TXLiteAVDemo.xcworkspace project and click Run to start debugging the demo.

    Step 5. Modify the demo source code

    The source code folder TRTCCallingDemo contains two subfolders: ui and model. The ui folder contains the UI code:

    File or Folder Feature Description
    TRTCCallingVideoViewController.swift Video call UI where calls can be answered or rejected.
    TRTCCallingAudioViewController.swift Audio call UI where calls can be answered or rejected.
    TRTCCallingContactViewController.swift UI for searching for contacts.

    Implementing Your Custom UI

    The [source code] folder TRTCCallingDemo contains two subfolders: ui and model. The model folder contains the implemented reusable open-source component TRTCCalling. You can find the API functions provided by this component in the TRTCCalling.h file.

    You can use the open-source component TRTCCalling to implement your own UI, i.e., only reusing the model to implement your custom UI.

    Step 1. Integrate SDKs

    The call component TRTCCalling depends on the TRTC SDK and IM SDK. You can integrate the two SDKs into your project by following the steps below:

    • Method 1: implement dependency through the CocoaPods repository
      pod 'TXIMSDK_iOS'
      pod 'TXLiteAVSDK_TRTC'

      You can get the latest version numbers of the two SDKs on the TRTC and IM homepages on GitHub.

    • Method 2: implement dependency through the local files
      If access to the CocoaPods repository is slow in your development environment, you can download the ZIP packages and manually integrate the SDKs into your project as instructed in the integration document.
      SDKDownload PageIntegration Guide
      TRTC SDK Download Integration documentation
      IM SDK Download Integration documentation

    Step 2. Configure permissions

    Apply for camera and mic permissions by adding Privacy - Camera Usage Description and Privacy - Microphone Usage Description in the info.plist file.

    Step 3. Import the TRTCCalling component

    Copy all the files in the following directory to your project:


    Step 4. Initialize and log in to the component

    1. Set the push information.
      [TRTCCalling shareInstance].imBusinessID = your business ID;
      [TRTCCalling shareInstance].deviceToken =  deviceToken;
    2. Call login(sdkAppID: UInt32, user: String, userSig: String, success: @escaping (() -> Void), failed: @escaping ((_ code: Int, _ message: String) -> Void)) to log in to the component. Enter the key parameters as shown below:
      sdkAppID You can view the `SDKAppID` of your application in the TRTC console.
      user ID of the current user, which is a string that can contain only letters (a–z and A–Z), digits (0–9), hyphens (-), and underscores (_).
      userSig UserSig.