AUI Kits is Alibaba Cloud's cross-platform service for real-time audio and video communication, supporting scenarios like voice chat and multi-user interaction. Its stable and flexible communication helps you quickly build applications with a low-code approach. This topic shows you how to integrate the voice chat room feature on iOS.
Source code
Download source code
To download the source code, see the GitHub open-source project.
Directory structure
├── iOS // Root directory for the iOS platform
│ ├── AUIVoiceRoom.podspec // podspec file
│ ├── Source // Source code files
│ ├── Resources // Resource files
│ ├── Example // demo code
│ ├── AUIRoomCore // Core component for interactive voice chat scenarios
│ ├── AUIBaseKits // Base UI components
│ ├── README.md // Readme
Environment requirements
-
Xcode 14.0 or later. We recommend that you use the latest stable release.
-
CocoaPods 1.9.3 or later.
-
A physical device running iOS 10.0 or later.
Prerequisites
-
You have completed the initial setup. For details, see Console configuration.
-
You have developed the required APIs on your server or deployed the provided server-side source code. For setup steps, see Server-side configuration and running.
Run the demo
-
After you download the source code, navigate to the
Exampledirectory and runpod install --repo-updateto install the SDK dependency. -
Open the project file AUIVoiceRoomExample.xcworkspace. In Signing & Capabilities, update the Team and Bundle Identifier.
-
For Team, select your Apple developer account.
-
For Bundle Identifier, enter your app's bundle ID.
Select the Automatically manage signing checkbox.
-
-
Open the iOS/Source/AUIVoiceRoomManager.swift file and update the server domain name.
let VoiceRoomServerDomain = "your_application_server_domain_name" -
Open the iOS/AUIRoomCore/Source/Core/Service/ARTCRoomRTCService.swift file and update the appId for your real-time audio and video application.
@objcMembers public class AUIRoomConfig: NSObject { public var appId = "your_appId" ... } -
Build and run the project on a physical device.
Build a voice chat room
Follow these steps to quickly integrate AUIVoiceRoom into your app and add voice chat room capabilities.
Integrate source code
-
Import AUIVoiceRoom.
After you download the repository, copy the iOS folder to your app's code directory, rename it to AUIVoiceRoom, and place it at the same level as your Podfile. You can delete the Example directory.
-
Update your Podfile to include the following:
AliVCSDK_ARTC: An audio and video client SDK for real-time audio and video. You can also use AliVCSDK_Standard or AliVCSDK_InteractiveLive. For more information, see iOS client.
-
AUIFoundation: The base UI component.
-
AUIMessage: The interactive messaging component.
-
AUIRoomCore: The core component for interactive voice chat scenarios.
-
AUIVoiceRoom: The source code for the voice chat room UI component.
# Requires iOS 10.0 or later platform :ios, '10.0' target 'YourAppTarget' do # Integrate the appropriate audio and video client SDK for your use case. # Supported SDKs: AliVCSDK_ARTC, AliVCSDK_Standard, AliVCSDK_InteractiveLive pod 'AliVCSDK_ARTC', '~> 6.10.0' # AUIFoundation pod 'AUIFoundation', :path => "./AUIVoiceRoom/AUIBaseKits/AUIFoundation/" # AUIMessage pod 'AUIMessage/AliVCIM', :path => "./AUIVoiceRoom/AUIBaseKits/AUIMessage/" # AUIRoomCore pod 'AUIRoomCore/AliVCSDK_ARTC', :path => "./AUIVoiceRoom/AUIRoomCore/" # AUIVoiceRoom pod 'AUIVoiceRoom', :path => "./AUIVoiceRoom/" end -
Run
pod install --repo-updateto complete the source code integration.
Project configuration
-
Open your project's Info.plist file and add the NSMicrophoneUsageDescription permission.
-
Open your project settings. In Signing & Capabilities, enable Background Modes.
Source code configuration
-
In AUIVoiceRoomManager.swift, update the application server domain name.
// AUIVoiceRoomManager.swift let VoiceRoomServerDomain = "your_application_server_domain_name" -
In ARTCRoomRTCService.swift, update the appId for your real-time audio and video application.
// ARTCRoomRTCService.swift @objcMembers public class AUIRoomConfig: NSObject { public var appId = "your_appId" ... }
API calls
You can now use the component API in other modules or your app's home page to add voice chat room features. The source code can also be modified as needed.
// Initialize before entering a voice chat room. Make sure the user is logged in to the app.
let user = ARTCRoomUser(uid) // Current user information
user.userNick = nick
user.userAvatar = avatar
let serverAuth = auth // The token obtained after app login, used for server-side security verification
AUIVoiceRoomManager.shared.setup(currentUser: user!, serverAuth: serverAuth)
// Open the voice chat room list
let listVC = AUIVoiceRoomListViewController()
self.navigationController?.pushViewController(listVC, animated: false)
// Create a voice chat room
AUIVoiceRoomManager.shared.createRoom(currVC: self)
// Join a voice chat room
AUIVoiceRoomManager.shared.enterRoom(roomId: roomInfo.roomId, currVC: self)
Results
For more information, see the demo.
FAQ
For more information about AUI Kits or for support, join our AUI customer support group on DingTalk by searching for group ID 35685013712.