twilio / twilio-video-app-ios

A collaboration application built with the Twilio Video iOS SDK
Apache License 2.0
248 stars 54 forks source link
ios objc swift twilio video webrtc

Twilio Video iOS App

This app is a sample video conferencing app that uses the Twilio Programmable Video SDK. The open source app can be easily configured by developers to try out real-time video and audio features.

App Preview

Features

Getting Started

Deploy Twilio Access Token Server

NOTE: The Twilio Function that provides access tokens via a passcode should NOT be used in a production environment. This token server supports seamlessly getting started with the collaboration app, and while convenient, the passcode is not secure enough for production environments. You should use an authentication provider to securely provide access tokens to your client applications. You can find more information about Programmable Video access tokens in this tutorial.

The app requires a back-end to generate Twilio access tokens. Follow the instructions below to deploy a serverless back-end using Twilio Functions.

  1. Install Twilio CLI.
  2. Run twilio login and follow prompts to login to your Twilio account.
  3. Run twilio plugins:install @twilio-labs/plugin-rtc.
  4. Run twilio rtc:apps:video:deploy --authentication passcode.
  5. The passcode that is output will be used later to sign in to the app.

The passcode will expire after one week. To generate a new passcode, run twilio rtc:apps:video:deploy --authentication passcode --override.

Troubleshooting

If any errors occur after running a Twilio CLI RTC Plugin command, or the application fails to validate a passcode, then try the following steps.

  1. Update your application to the latest source
  2. Run twilio plugins:update to update the RTC plugin to the latest version.
  3. Run twilio rtc:apps:video:delete to delete any existing authentication servers.
  4. Run twilio rtc:apps:video:deploy --authentication passcode to deploy a new authentication server.

Configure Signing

  1. Open VideoApp/VideoApp.xcodeproj with Xcode.
  2. In Xcode navigate to the Signing & Capabilities pane of the project editor for the Video-Community target.
  3. Change Team to your team.
  4. Change Bundle identifier to something unique.
  5. Check Automatically manage signing.

Run

  1. In Xcode use the Scheme menu to select the Video-Community scheme.
  2. In Xcode use the Scheme menu to select a destination. Cameras do not work in the simulator so select a device for best results.
  3. Run ⌘R the app.

The Video-Internal scheme uses authentication that is only available to Twilio employees in order to make internal testing easier.

Start Video Call

For each device:

  1. Run the app.
  2. Enter any unique name in the Your name field.
  3. Enter the passcode from Deploy Twilio Access Token Server in the Passcode field.
  4. Tap Sign in.
  5. Enter a room name.
  6. Tap Continue.
  7. Configure the camera and microphone and tap Join Now.

The passcode will expire after one week. Follow the steps below to sign in with a new passcode.

  1. Generate a new passcode.
  2. In the app tap Settings > Sign Out.
  3. Repeat the steps above.

NOTE: Usage charges will apply for video calls. See pricing for more information.

SwiftUI

This app uses SwiftUI. SwiftUI and Combine work particularly well for the video collaboration features in this app, which involve a lot of real-time state changes. SwiftUI has allowed us to build a better app with a lot less code.

If your app uses UIKit or an older version of SwiftUI, you should still be able to use a lot of code from this repo in your app. Here are some tips:

Tests

Unit Tests

For unit tests use:

UI Tests

UI tests require credentials that are only available to Twilio employees.

Known Issues

  1. Running tests ⌘U will crash if the app was run ⌘R on the device previously. See issue #12 for a workaround and more details.

Related

For Twilions

Twilio employees should follow these instructions for internal testing.

License

Apache 2.0 license. See the LICENSE file for details.