iOS
Quickly run the ARTC sample project to experience real-time audio and video features.
Download the sample source code
Alibaba Cloud provides an open source sample project that demonstrates ARTC SDK API usage, helping you understand and integrate SDK features. See the iOS sample project repository.
Prerequisites
Before running the sample project, ensure your development environment meets the following requirements:
-
Development tool: Xcode 14.0 or later. Use the latest stable version if possible.
-
Recommended setup: CocoaPods 1.9.3 or later.
-
Test device: A physical iOS device running iOS 9.0 or later.
Use a physical device for testing. Simulators may lack certain features.
-
Network: A stable network connection is required.
-
Application setup: Obtain the AppID and AppKey for your ApsaraVideo Real-time Communication application. For more information, see Create Application.
Procedure
Step 1: Get the sample project
Clone the ARTC sample project to your local machine:
git clone https://github.com/MediaBox-Demos/amdemos-artc
This repository contains sample projects for multiple native platforms using the ARTC SDK. The iOS sample project is located in the iOS/ folder.
The sample project includes client-side code for generating tokens to help you test.
The following shows the file structure of the iOS/ARTCExample project.
├── iOS // Root directory of the iOS project
│ ├── ARTCExample // API example source code
│ ├── Common // Common modules
│ ├── ARTCTokenHelper.swift // Set AppId, AppKey, and other info
│ ├── ... // Other files
│ ├── QuickStart // Quick-start modules
│ ├── TokenGenerate // Token generation and channel join
│ ├── VideoCall // Quick implementation of video calls
│ ├── VoiceChat // Quick implementation of chat rooms
│ ├── BasicUsage // Basic features
│ ├── AudioBasicUsage // Common audio operations and settings
│ ├── VideoBasicUsage // Common video operations and settings
│ ├── CameraCommonSetting // Standard camera settings
│ ├── SEIUsage // Send and receive SEI messages
│ ├── DataChannelMessage // Send and receive custom messages
│ ├── ScreenShare // Screen sharing
│ ├── StreamMonitoring // Monitor stream quality during calls
│ ├── PlayAudioFiles // Play background music and sound effects
│ ├── AdvancedUsage // Advanced features
│ ├── ProcessAudioRawData // Raw audio data
│ ├── ProcessVideoRawData // Raw video data
| |—— CustomAudioCapture // Custom audio capture
| |—— CustomAudioRender // Custom audio playback
| |—— CustomVideoCapture // Custom video capture
| |—— CustomVideoRender // Custom video rendering
│ ├── CustomVideoProcess // Custom video processing
| |—— PreJoinChannelTest // Network and device detection before joining
| |—— PictureInPicture // Picture-in-Picture (PiP)
| |—— H265 // H.265 encoding
| |—— IntelligentDenoise // Smart noise reduction
| |—— LocalRecord // Local recording
│ ├── Setting // Settings module
│ ├── ... // Other project files
│ ├── ARTCExample.xcodeproj // Demo project file
│ ├── ARTCExample.xcworkspace // Demo workspace file
│ ├── Podfile // Demo Podfile
Step 2: Configure the sample project
-
After downloading the source code, open the iOS folder.
-
In the iOS folder, run the command “pod install --repo-update” to automatically install the required SDK dependencies.
-
Open the project file
ARTCExample.xcworkspace. -
Configure your ApsaraVideo Real-time Communication AppID and AppKey.
Open
iOS/ARTCExample/Common/ARTCTokenHelper.swiftand enter the AppID and AppKey you obtained from the console.
// ARTCTokenHelper.swift
class ARTCTokenHelper: NSObject {
/**
* RTC AppId
*/
public static let AppId = "<ApsaraVideo Real-time Communication AppID>"
/**
* RTC AppKey
*/
public static let AppKey = "<ApsaraVideo Real-time Communication AppKey>"
...
}
Step 3: Compile and run the sample project
-
Select the "ARTCExample" target, connect a physical device, and compile the project.
-
Run the app to experience the API examples.
|
Run the demo on a physical device and click Implement video call. |
Have two devices join the same channel. Enter the same ChannelID (for example, |
Start the real-time audio and video call. |
Next steps
To integrate the ARTC SDK into your own project, see Implement video calls on iOS.