Published in

Quickstart with Agora UIKit for iOS

When adding a video chat to your own application, you might not want to read even more documentation. With Agora UIKit, you don’t have to think about much beyond what you already know about building familiar elements, such as a UIView.

This guide is a very short intro to Agora UIKit for iOS. To see the full guide, including code samples for macOS check it out here:

The GitHub repository of this library can be found here:


  • An Agora developer account (see How To Get Started with Agora)
  • Xcode 11.0 or later
  • An iOS device with minimum iOS 13.0
  • A basic understanding of iOS development
  • CocoaPods (if not using Swift Package Manager)


Start by creating an iOS or macOS project in Xcode.

Swift Package Manager (Recommended, iOS Only)

Add the URL of this repository to your Xcode 11+ Project.

Go to File > Swift Packages > Add Package Dependency, and paste in this link:

When installing, make sure you select the AgoraUIKit checkbox when choosing the package products.

Xcode sometimes has issues downloading large libraries such as the Agora SDK. If any errors are thrown, in Xcode select File > Swift Packages > Reset Package Caches.


To install the CocoaPod AgoraUIKit_iOS or AgoraUIKit_macOS, your Podfile should look like this:

target 'Agora-UIKit-Project' do
pod 'AgoraUIKit_iOS', '~> 1.8.0'

The latest AgoraUIKit release at the time of writing this post is v1.5.0

Run pod init, and open the .xcworkspace file to get started.

Add authorisation for the app to use the camera and microphone. To do this, open up the Info.plist file at the root of your Xcode project and add NSCameraUsageDescription along with NSMicrophoneUsageDescription.

For more information on requesting authorisation for media capture, check out this article from Apple.

Adding Video Streaming

If you want a ViewController that simply loads a video feed, the entire ViewController can look like this:

import UIKit
import AgoraUIKit_iOS

class ViewController: UIViewController {
var agoraView: AgoraVideoViewer!
override func viewDidLoad() {
self.agoraView = AgoraVideoViewer(
connectionData: AgoraConnectionData(
appId: <#Agora App ID#>,
appToken: <#Agora Token or nil#>
// fill the view
// join the channel "test"
agoraView.join(channel: "test", as: .broadcaster)

That’s all that’s required when using Agora UIKit in the most basic way. However, this does not take tokens into consideration, and tokens are required in production apps using Agora for security.

Token Integration

Tokens are another step that can slow down launching a product with Agora. Several blogs and repositories are available for help with understanding tokens; including a prebuilt token server in Golang, a 2-Click setup guide and information about fetching a token into your Swift app.

With Agora UIKit, you can simply set the tokenURL to the location of your token server, and Agora UIKit will take care of the rest, assuming that it follows the endpoint structures shown in the Golang token server repository. To do so, you will need to define an AgoraSettings object, assign the tokenURL value, and then apply the settings object when creating your AgoraVideoViewer object:

let agoraSettings = AgoraSettings()
agSettings.tokenURL = "https://<heroku url>"
agoraView = AgoraVideoViewer(
connectionData: AgoraConnectionData(
appId: <#Agora App ID#>
agoraSettings: agoraSettings

Now, whenever you’re connecting to a new channel, use the join method that asks for a Boolean fetchToken value, and set that to true:

channel: "test", as: .broadcaster, fetchToken: true


Creating a production application that uses Agora’s network for video calling is now easier than ever. The same classes and methods seen above can also be added to a macOS application.

You can head over to the Advanced Agora UIKit blog to unlock the full potential of Agora UIKit for iOS and macOS. Many more customisations and enhancements can be made using this library.

Other Resources

For more information about building applications using SDKs, take a look at the Agora Video Call Quickstart Guide and Agora API Reference.

I also invite you to join the Developer Slack community.




Agora delivers cutting edge APIs for developers. Our blog covers the world of technology.

Recommended from Medium

Flutter for SwiftUI Developers

iOS 14: Is It Worth Updating

🔷 Unit Testing CoreBluetooth: Part 1

7 Alfred Workflows For Developers, Designers, and Bloggers

Adding a guided tour to your iOS app

Change version of iPhone in the Simulator (Android Studio, Flutter)

iOS Vision Text Document Scanner

Swift 5.3 — Sailing towards Performance and Quality

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Max Cobb

Max Cobb

Excited about all things Augmented Reality! Developer Evangelist at

More from Medium

Send data with navigation from View controller to SwiftUI view

Calling asynchronous Firebase APIs from Swift

SwiftUI + Combine + MVVM Experiences with Spotify API: Chaining Network Requests, Observable…

Create an Omnitrix watchOS App Using SwiftUI