tencent cloud

Feedback

Last updated: 2024-04-12 11:29:00
    This article will introduce how to complete the integration of the TUIRoomKit Component in the shortest time. By following this document, you will complete the following key steps within an hour and ultimately obtain an audio/video conference function with a complete UI interface.

    Environment preparation

    iOS 13.0 and higher.
    Xcode 12.0 and higher.
    Swift 4.2 and higher.

    Activate the service

    Before initiating a meeting with TUIRoomKit, you need to activate the exclusive multi-person audio and video interaction service for TUIRoomKit on the console. For specific steps, please refer to Activate Service.

    Integrate the TUIRoomKit Component

    Pull remote CocoaPods integration (recommended when there is no source code modification)

    1. Add the following dependencies to your Podfile file.
    pod 'TUIRoomKit'
    2. Execute the following command to install the Component.
    pod install
    3. If you cannot install the latest version of TUIRoomKit, execute the following command to update the local CocoaPods repository list.
    pod repo update

    Source code integration (recommended when there are source code modifications)

    1. Download the TUIRoomKit source code from GitHub. Drag directly into your project directory: TUIRoomKit/iOS/TUIRoomKit.
    
    
    
    2. Modify the path of the TUIRoomKit component in your Podfile, for example:
    pod 'TUIRoomKit', :path => "../TUIRoomKit/"
    3. Execute installation command.
    pod install

    Quick setup

    Step 1: Project Configuration

    To use the audio and video functions, you need to authorize the use of microphone, camera and photo album. Add the following items to the App's Info.plist, corresponding to the prompt messages for the microphone, camera, and photo album when the system pops up the authorization dialog box.
    <key>NSCameraUsageDescription</key>
    <string>TUIRoom needs access to your Camera permission</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>TUIRoom needs access to your Mic permission</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>TUIRoom needs access to your Photo Library</string>
    
    
    

    Step 2: Log in TUI Component

    Add the following code to your project. Its function is to complete the initialization of TUI components by calling the relevant interfaces in TUICore. This step is very critical, because all functions of TUIRoomKit can only be used normally after successful login, so please be patient and check whether the relevant parameters are configured correctly:
    import TUICore
    
    TUILogin.login(1400000001, // Please replace with the SDKAppID obtained in step 1
    userID: "998", // Please replace with your UserID
    userSig: "xxxxxxxxxx") { // You can calculate a UserSig in the Console and fill it in this position
    print("login success")
    } fail: { (code, message) in
    print("login failed, code: \\(code), error: \\(message ?? "nil")")
    }
    Parameter Description Here is a detailed introduction to the key parameters used in the login function:
    SDKAppID:You have already obtained it in Activate the service, so it will not be repeated here.
    UserID:The ID of the current user, string type, only allows to contain English letters (a-z and A-Z), numbers (0-9), hyphens (-), and underscores (_).
    UserSig:Encrypt the SDKAppID, UserID, etc. with the SDKSecretKey obtained in Activate the service to get the UserSig, which is a ticket for authorization and is used for Tencent Cloud to recognize whether the current user can use the TRTC service. You can create a temporarily available UserSig through the UserSig Tools through the project sidebar in the console.
    
    
    
    For more information, please refer to the UserSig related.

    Step 3: Set user nickname and avatar

    The user's username and avatar can be set by calling setSelfInfo of TUIRoomEngine, which can be set in the callback of successful login.
    import TUIRoomEngine
    
    TUIRoomEngine.setSelfInfo(userName: "xxx", avatarUrl: "xxx") {
    print("setSelfInfo success")
    } onError: { code, message in
    print("setSelfInfo failed, code:\\(code),message:\\(message)")
    }

    Step 4: The host start a quick conference

    The main conference page is ConferenceMainViewController. Just call quickStartConference to initiate a quick conference and jump to ConferenceMainViewController in the onConferenceStarted callback.
    import TUIRoomKit
    
    // CreateRoomViewController for your own ViewController
    class CreateConferenceViewController: UIViewController {
    private var conferenceViewController: ConferenceMainViewController?
    func quickStartConferenceAction() {
    conferenceViewController = ConferenceMainViewController()
    conferenceViewController?.setConferenceObserver(observer: self)
    conferenceViewController?.quickStartConference(conferenceId: "123456")
    }
    }
    extension CreateConferenceViewController: ConferenceObserver {
    func onConferenceStarted(conferenceId: String, error: ConferenceError) {
    if error == .success, let vc = conferenceViewController {
    navigationController?.pushViewController(vc, animated: true)
    }
    conferenceViewController = nil
    }
    }

    Step 5: Members join the conference

    The main conference page is ConferenceMainViewController. Just call joinConference to join the conference and jump to ConferenceMainViewController in the onConferenceJoined callback.
    import TUIRoomKit
    
    // EnterRoomViewController for your own ViewController
    class EnterConferenceViewController: UIViewController {
    private var conferenceViewController: ConferenceMainViewController?
    private func joinConferenceAction() {
    conferenceViewController = ConferenceMainViewController()
    conferenceViewController?.setConferenceObserver(observer: self)
    conferenceViewController?.joinConference(conferenceId: "123456")
    }
    }
    extension EnterConferenceViewController: ConferenceObserver {
    func onConferenceJoined(conferenceId: String, error: ConferenceError) {
    if error == .success, let vc = conferenceViewController {
    navigationController?.pushViewController(vc, animated: true)
    }
    conferenceViewController = nil
    }
    }

    More Features

    UI Widget Access

    Import the chat widget using CocoaPods, with the following specific steps:
    1. Add the following dependencies to your Podfile file.
    pod 'TUIChat' # [Optional] TUIChat Widget
    2. Execute the following command to install the component.
    pod install

    Common Problems

    If you encounter problems when using TUIRoomKit, please check the FAQ document first.

    Suggestions and Feedback

    If you have any suggestions or feedback, please contact info_rtc@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