Skip to content

A simple native WebRTC demo iOS app using swift

License

Notifications You must be signed in to change notification settings

n1kron/WebRTC-iOS

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebRTC-iOS

A simple native WebRTC demo iOS app using swift.

Early Xcode 11 adapters? check out xcode-11 branch.

Screenshots

Disclaimer

This demo app's purpose is to demonstrate the bare minimum required to establish peer to peer connection with WebRTC. This is not a production ready code! In order to have a production VoIP app you will need to have a real signaling server (not a simple broadcast server like in this example), deploy your own Turn server(s) and probably integrate CallKit and push notifications.

Requirements

  1. Xcode 10.2 or later
  2. Cocoapods
  3. Node.js + npm

Setup instructions

  1. Start the signaling server:
    1. Navigate to the signaling folder.
    2. Run npm install to install all dependencies.
    3. Run node app.js to start the server.
  2. Navigate to WebRTC-Demo-app folder
  3. Run pod install
  4. Open WebRTC-Demo.xcworkspace
  5. Open Config.swift and set the defaultSignalingServerUrl variable to your signaling server ip/host. Don't use localhost or 127.0.0.1 if you plan to connect other devices in your network to your mac.
  6. Build and run on devices or on a simulator (video capture is not supported on a simulator).

Run instructions

  1. Run the app on two devices with the signaling server running.
  2. Make sure both of the devices are connected to the signaling server.
  3. On the first device, click on 'Send offer' - this will generate a local offer SDP and send it to the other client using the signaling server.
  4. Wait until the second device receives the offer from the first device (you should see that a remote SDP has arrived).
  5. Click on 'Send answer' on the second device.
  6. when the answer arrives to the first device, both of the devices should be now connected to each other using webRTC, try to talk or click on the 'video' button to start capturing video.
  7. To restart the process, kill both apps and repeat steps 1-6.

CallKit integration

Disclaimer: I am not sure if this is the best way doing it but this has worked for me so far:

  1. Configure WebRTC audio session to use manual audio and disable audio:
    1. RTCAudioSession.sharedInstance().useManualAudio = true
    2. RTCAudioSession.sharedInstance().isAudioEnabled = false
  2. On your CXProvider delegate's provider(CXProvider, didActivate: AVAudioSession) method:
    1. Call RTCAudioSession.sharedInstance().audioSessionDidActivate with the AVAudioSession from the CXProvider
    2. Enable audio: RTCAudioSession.sharedInstance().isAudioEnabled = true
  3. On your CXProvider delegate's provider(CXProvider, didDeactivate: AVAudioSession) call RTCAudioSession.sharedInstance().audioSessionDidDeactivate with the AVAudioSession from the CXProvider

WebRTC and CallKit talk from 2016: https://youtu.be/JB2MdcY1MKs?t=6m23s

References:

Credits:

About

A simple native WebRTC demo iOS app using swift

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 97.3%
  • JavaScript 2.2%
  • Ruby 0.5%