Agora provides an open-source Agora-macOS-Tutorial-Swift-1to1 sample project on GitHub. This document introduces how to run this project and experience a video call implemented by the Agora SDK.
To create an Agora project, do the following:
Agora automatically assigns each project an App ID as a unique identifier.
To copy this App ID, find your project on the Project Management page in Agora Console, and click the icon in the App ID column.
To ensure communication security, Agora recommends using tokens to authenticate users joining a channel.
For testing purposes, Agora Console supports generating RTC temporary tokens. To generate an RTC temporary token:
Download the Basic-Video-Call repository, and navigate to the Basic-Video-Call/One-to-One-Video/Agora-macOS-Tutorial-Swift-1to1/Agora-Mac-Tutorial-Swift
folder.
Open the AppID.swift
file, and enter the App ID and the temporary token.
// Replace <#Your App ID#> with the App ID of your Agora project, and add quotation marks. For example, "xxxxxx".
let AppID: String = <#Your App ID#>
// Replace <#Temp Token#> with the temporary token generated in Agora Console, and add quotation marks. For example, "xxxxxx".
let Token: String? = <#Temp Token#>
Open the VideoChatViewController.swift
file, and replace demoChannel1
with the channel name that you use to generate the temporary token.
func joinChannel() {
AgoraKit.joinChannel(byToken: Token, channelId: "demoChannel1", info:nil, uid:0) { (sid, uid, elapsed) -> Void in
}
}
Integrate the Agora SDK into the sample project, as follows:
libs
folder to the Agora-Mac-Tutorial-Swift
folder.Run the sample project to start a video call, as follows:
Open and run the Agora-Mac-Tutorial-Swift.xcodeproj
sample project on a macOS device. When the sample project runs successfully, you can see the following interface.
If you want to experience a one-to-one video call, you can also use the Agora Web sample app to interact with your macOS device. Ensure that you enter the same App ID, channel name, and temporary token in the Agora Web sample app as in the OpenLive sample app.
See the code of the main functions and the front-end style in the VideoChatViewController.swift
file of the sample project for your reference.
Agora provides the following additional video call sample projects on GitHub: