-
- 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.
-
Node.js
-
Ionic:
$ npm install -g ionic
-
Xcode
-
Android Studio
-
Clone this repo
-
Change directory to the sample project
-
Run:
$ npm install
-
Add the Cordova-OpenTok-Plugin:
$ ionic cordova plugin add https://github.com/msach22/cordova-plugin-opentok/
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 test purposes, you can get a test session ID and token for your project at your TokBox account page.
Open the src/pages/home/home.ts
file in your project and set the apiKey
, sessionId
, and token
values to the API key, session ID, and token:
// Set Credentials
this.apiKey = ''; // Add your API key.
this.sessionId = ''; // Add the session ID.
this.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 developer guides on session creation and token creation.
- In the root directory of the sample project, run
ionic serve
.- This is needed to copy over the files to the
www
folder
- This is needed to copy over the files to the
- Next, run
ionic 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 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.
- In the root directory of the sample project, run
ionic serve
.- This is needed to copy over the files to the
www
folder
- This is needed to copy over the files to the
- Next, run
ionic cordova prepare android
. - Open Xcode.
- Click
Open another project...
- Navigate to the
platforms/ios
subdirectory of this project and selectMyApp.xcodeproj
. - Sign the project.
- Run.