How to build Audio Chat / Video Chat in iOS using WebRTC

Daiki Matsudate
2 min readJan 10, 2017

--

Recentry, I need to build the Audio Chat and Video Chat in iOS apps. It was difficult to collect infomation of implement WebRTC in iOS, so I’d like to tell you about how to use WebRTC in iOS.

Note: This article describes implementation on the iOS client, and does not mention infrastructure configuration or server side implementation.

What is WebRTC?

WebRTC is a technology to realize Real-Time Communication (RTC) such as voice call, video call, etc. on browser and mobile application. It is suppported by Google, Mozilla, Opera etc. The official page itself seems to be operated by the Google Chrome team.

Supported browsers and platforms

It is supported Chrome, Firefox and Opera because it is developed by each company, and Android and iOS are also supported.

How to call or do video chat on your device?

There are samples that are officially provided, but, unfortunately, all these samples only run on the browser. Where is the sample for iOS? ISBX provides the sample for iOS, ISBX/apprtc-ios, which is based on official AppRTC. When you clone the repository and build it, you will be prompted to enter the Room ID. After making the room appropriately, build the same application on another device and enter the same Room ID, video chat with that will start.

Frameworks for iOS

In official guideline, they say “Build yourself”, but there are people who are willing to put it in Cocoapod or Carthage easily. I’ll show you some of open source libraries below:

It is the iOS implementation of AppRTC introduced earlier. If you want to use AppRTC as it is, you can install it via CocoaPods.

pod install AppRTC

Initialization of SSL Peer Connection, addition method of video chat is also gathered together with code sample.

  • libjingle_peerconnection
    This AppRTC also uses this framework. Pristine, Inc. have modified the build script of iOS included in WebRTC’s original, and distributed the binary on Cocoapods as a framework.
  • Anakros/WebRTC
    You can install it here either in CocoaPods or Carthage. It is roughly the same as `libjingle_peerconnection`, but some header files included are different. They build https://chromium.googlesource.com/external/webrtc/ by usingwebrtc/build/ios/build_ios_libs.sh .

Note: Since it is not compatible with the i386, x86–64 architecture here, it can not be built with the simulator

Since it is built from the same WebRTC binary, I think that basically it does not matter which one you choose.
I chose Arakros/WebRTC which can be installed at Carthage.

Conclusion & Next step

Although there were few articles summarized for iOS, the investigation was difficult, but I would appreciate it if it is helpful to those who have to face WebRTC on iOS.
Since the apprtc-ios is written in Objective-C and we will make models and wrappers by ourselves even if we utilize other libraries, so next time I want to put the knowledge gained in development into my new Swift’s library.

Resouces

--

--