Quick integration on iOS

更新时间:
复制 MD 格式

This topic describes how to integrate AUI Kits for chit-chat rooms with an iOS application.

Source code

Download link

You can download the source code from GitHub.

Directory structure

The source code contains the AUIRoomCore and AUIMessage components. Directory structure:

├── AUIRoomCore
│   ├── AUIRoomCore.podspec                // The description file of the pod.
│       ├── Core                           // The scenario-based API operations.
│           ├── Model                      // The models such as the room and users.
│ ├── Service // The Real-Time Communication (RTC) feature in the room.
│           ├── VoiceRoom                  // The chit-chat scenario-based API operations.
│           ├── KaraokeRoom                // The karaoke scenario-based API operations. You can delete the operations based on your business requirements.
│       ├── Imp                            // The default configurations of the room API.
│       ├── Login                          // The information that is used to log on to the demo. You can delete the information if you do not need the information.
│   ├── README.md
├── AUIBaseKits
│    ├── AUIMessage

Environment requirements

  • Xcode 14.0 or later. We recommend that you use the latest official version.

  • CocoaPods 1.9.3 or later.

  • A physical device that runs iOS 10.0 or later.

Prerequisites

An application is created. The server-side API operations are developed or directly deployed from the source code. For more information, see Integrate and run AUI Kits AppServer for chit-chat rooms.

Integrate components

Procedure

  1. Import the AUIRoomCore and AUIMessage components: After the repository code is downloaded, copy the AUIRoomCore and AUIMessage folders to your application code directory at the same level as your Podfile file.

  2. Add the following dependencies to your Podfile file:

    • AliVCSDK_ARTC: ApsaraVideo MediaBox SDK for Alibaba Real-time Communication (ARTC). You can also import AliVCSDK_Standard or AliVCSDK_InteractiveLive. For more information, see Integrate ApsaraVideo MediaBox SDK for iOS.

    • AUIRoomCore: the API source code for interactive entertainment and communication. Online chit-chat rooms are supported. You can remove the code that is no longer required, such as the code for logons.

    • AUIMessage: By default, AUIMessage and the interactive messaging SDK are required for online chit-chat rooms.

    # Online chit-chat rooms are supported in iOS 10.0 or later.
    platform :ios, '10.0'
    
    target' Your application target' do
        # Integrate ApsaraVideo MediaBox SDK based on your business requirements. AliVCSDK_ARTC, AliVCSDK_Standard, and AliVCSDK_InteractiveLive are supported.
        pod 'AliVCSDK_ARTC', '~> 6.10.0'
    
        # Download the source code of the interactive messaging SDK to the same level as the Podfile file. AUIMessage and the interactive messaging SDK are required for online chit-chat rooms.
        pod 'AUIMessage/AliVCIM', :path => "./AUIMessage/"
    
        # Integrate the interactive entertainment and chit-chat component. The component depends on AliVCSDK_ARTC. You must specify the SDK name in the source code.
        pod 'AUIRoomCore/AliVCSDK_ARTC', :path => "./AUIRoomCore/"
    
        # Import API operations for chit-chat rooms.
        pod 'AUIRoomCore/VoiceRoomAPI', :path => "./AUIRoomCore/"
    end
  3. Run the pod install --repo-update command.

  4. The source code is integrated.

Configure your project

  • Open the info.Plist file of the project and add the NSMicrophoneUsageDescription permission.

  • Click the Signing & Capabilities tab of your project and enable Background Modes.

Modify the source code

After the prerequisites are met, open the ARTCRoomRTCService.swift file and specify the ID of the ARTC application.

// ARTCRoomRTCService.swift
@objcMembers public class ARTCRoomConfig: NSObject {
    
    public var appId = "The ID of your ARTC application."
    ...
}

Call API operations

After the preceding steps are complete and UI is developed, you can call API operations to use the chit-chat room feature.

For more information, see the AUIVoiceRoomViewController class in the AUIVoiceRoom component in the source code.