Coder Social home page Coder Social logo

fahadalbukhari / video-quickstart-swift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twilio/video-quickstart-ios

0.0 1.0 0.0 8.46 MB

Twilio Video Quickstart for iOS with Swift

Home Page: https://www.twilio.com/docs/api/video

License: MIT License

Swift 82.81% Objective-C 16.73% Ruby 0.46%

video-quickstart-swift's Introduction

Download Docs

Twilio Video Quickstart for Swift

NOTE: These sample applications use the Twilio Video 2.0.0-beta1 APIs. We will continue to update them throughout the beta period. For examples using our Generally Available 1.x APIs, please see the 1.x branch.

Get started with Video on iOS:

Setup

This project uses Apple's Swift 3.2 programming language for iOS.

If you haven't used Twilio before, welcome! You'll need to Sign up for a Twilio account first. It's free!

Note: if your app uses Objective-C see video-quickstart-objective-c.

CocoaPods

  1. Install CocoaPods 1.0.0+.

  2. Run pod install from the root directory of this project. CocoaPods will install TwilioVideo.framework and then set up an xcworkspace.

  3. Open VideoQuickStart.xcworkspace.

Note: You may need to update the CocoaPods Master Spec Repo by running pod repo update master in order to fetch the latest specs for TwilioVideo.

Manual Integration

You can integrate TwilioVideo.framework manually by following these install instructions.

Quickstart

Running the Quickstart

To get started with the Quickstart application follow these steps:

  1. Open this VideoQuickStart.xcworkspace in Xcode

  1. Type in an identity and click on "Generate Access Token" from the Testing Tools page.

Note: If you enter the Room Name, then you can restrict this user's access to the specified Room only. Ideally, you want to implement and deploy an Access Token server to generate tokens. You can read more about setting up your own Access Token Server in this section. Read this tutorial to learn more about Access Tokens.

  1. Paste the token you generated in the earlier step in the ViewController.swift.

  1. Run the Quickstart app on your iOS device or simulator.

  1. As in Step 2, generate a new Token for another identity (such as "Bob"). Copy and paste the access token into ViewController.swift (replacing the one you used earlier). Build and run the app on a second physical device if you have one, or the iPhone simulator.

  2. Once you have both apps running, enter an identical Room name (such as "my-cool-room") into both apps, and tap "Connect" to connect to a video Room (you'll be prompted for mic and camera access on the physical device). Once you've connected from both devices, you should see video!

Using a Simulator

You can use the iOS Simulator that comes with Xcode to do your testing, but local video will not be shared since the Simulator cannot access a camera.

Note: If you have an iOS device, you can now run apps from Xcode on your device without a paid developer account.

Examples

You will also find additional examples that provide more advanced use cases of the Video SDK. The currently included examples are as follows:

  • AudioDevice - Provide your own means to playback and record audio using a custom TVIAudioDevice and CoreAudio.
  • AudioSink - Access raw audio samples and record them to disk using AVFoundation. Perform live voice recognition using Apple's Speech framework.
  • ARKit - Captures augmented reality content with ARKit and uses SceneKit to place objects in the virtual scene. The resulting rendering is previewed locally, and shared in a TVIRoom via a custom TVIVideoCapturer source. This app requires Xcode 9 & iOS 11.
  • CallKit - Shows how to use Twilio Video with the CallKit framework.
  • DataTrack - Shows how to use the Data Track APIs for interactive drawing.
  • Screen Capturer - Shows how to use TVIScreenCapturer to capture the contents of a UIView, and how a custom TVIVideoCapturer can be implemented to do the same.

Setup an Access Token Server

Using Twilio's Video client within your applications requires an access token. Access Tokens are short-lived credentials that are signed with a Twilio API Key Secret and contain grants which govern the actions the client holding the token is permitted to perform.

Configuring the Access Token Server

If you want to be a little closer to a real environment, you can download one of the video Quickstart server applications - for instance, Video Quickstart: PHP and either run it locally, or install it on a server. You can review a detailed tutorial.

You'll need to gather a couple of configuration options from the Twilio developer console before running it, so read the directions on the Quickstart. You'll copy the config.example.php file to a config.php file, and then add in these credentials:

Credential Description
Twilio Account SID Your main Twilio account identifier - find it on your dashboard.
API Key Used to authenticate - generate one here.
API Secret Used to authenticate - just like the above, you'll get one here.

Use whatever clever username you would like for the identity. If you enter the Room Name, then you can restrict this users access to the specified Room only. Read this tutorial for more information on Access Tokens.

A Note on API Keys

When you generate an API key pair at the URLs above, your API Secret will only be shown once - make sure to save this in a secure location.

Running the Video Quickstart with ngrok

Because we suggest that you run your video chat application on actual iOS device so that you can use the camera on the device, you'll need to provide an externally accessible URL for the app (the iOS simulator will be fine with localhost). Ngrok creates a publicly accessible URL that you can use to send HTTP/HTTPS traffic to a server running on your localhost. Use HTTPS to make web connections that retrieve a Twilio access token.

When you get a URL from ngrok, go ahead and update ViewController.swift with the new URL. If you go down this path, be sure to follow the directions in the comments in the viewDidLoad() method at the top of the source file - you will need to uncomment one line, and comment out another. You will also need to update the code if your ngrok URL changes.

For this Quickstart, the Application transport security settings are set to allow arbitrary HTTP loads for testing your app. For production applications, you'll definitely want to retrieve access tokens over HTTPS/SSL.

More Documentation

You can find more documentation on getting started as well as our latest Docs below:

Issues and Support

Please file any issues you find here on Github.

For general inquiries related to the Video SDK you can file a support ticket.

License

MIT License

video-quickstart-swift's People

Contributors

bmctigue avatar ceaglest avatar girtis avatar idelgado avatar jefflinwood avatar kwhinnery avatar llsourcell avatar markandrus avatar paynerc avatar piyushtank avatar pt-old avatar rfbrazier avatar vassjozsef avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.