-
- This sample application shows how to connect to an OpenTok session, publish a stream, and subscribe to a single stream in an iOS and Android application.
-
- This sample application shows how to connect to an OpenTok session and use signaling to create a basic iOS and Android chat application.
-
- This sample application shows how to connect to an OpenTok session, publish a stream, and subscribe to multiple streams in an iOS and Android application.
-
Install node.js
-
Install Cordova:
npm install -g cordova
-
Install and update Xcode (you will need a Mac)
-
Install and update Android Studio
-
Clone this repo
-
In your terminal, change your directory to the root of the sample project you want to run.
-
Run the command:
npm install
to install required node modules
-
Run the command:
cordova platform add ios
to add iOS your project
-
Run:
cordova platform add android
to add Android your project
Before running the application, you need to configure it to use the API key for your OpenTok project, along with an OpenTok session ID and token. For development purposes, you can obtain a session ID and token by navigating to your TokBox account page, selecting a project, and scrolling to the bottom of the page where it says Generate Token
.
Open the wwww/js/config.js
file in your project and set the apiKey
, sessionId
, and token
values to the API key, session ID, and token you obtained from your TokBox account:
// Set Credentials
var apiKey = ''; // Add your API key.
var sessionId = ''; // Add the session ID.
var token = ''; // Add the token.
An OpenTok session connects different clients letting them share audio-video streams and send messages. Clients in the same session can include iOS, Android, and web browsers.
For testing, you can use a session ID and token generated at your TokBox account page. However, the final application should obtain these values using the OpenTok server SDKs. For more information, see the OpenTok server SDK guides on session and token creation.
- In the root directory of the sample project, run
cordova prepare android
. - Open Android Studio.
- Click
Open an existing Android Studio project
. - Navigate to the
platforms/android
subdirectory of this project and select thebuild.gradle
file. - Click
OK
to use the Gradle wrapper. - Click run.
Note: If you're using the simulator, you will see a black container for your publisher since the simulator doesn't have a camera.
Add the following to the project's info.plist
file:
<key>NSCameraUsageDescription</key>
<string>The camera is required to publish video</string>
<key>NSMicrophoneUsageDescription</key>
<string>The microphone is required to publish audio</string>
Make sure to update the description of each permission request to what best fits your needs.
- In the root directory of the sample project, run
cordova prepare ios
. - Open Xcode.
- Click
Open another project...
- Navigate to the
platforms/ios
subdirectory of this project and selectOpenTokCordova.xcodeproj
. - Sign the project.
- Run.