This project implements opentok/cordova-plugin-opentok in Ionic 4 and is meant as a boiler plate as well as to highlight issues faced during implementation.
Following instructions will get you a copy of the project up and running on your local machine
(You may skip prerequisites if you have a latest Cordova environment running)
Download and install NodeJS from: http://nodejs.org. Verify installation using following command
$ node --version
$ npm install -g ionic cordova
The Android SDK needs the Java Development Kit (JDK) to be installed, version 1.7 or later. Note that the Java Runtime Environment (JRE) is not sufficient, you will need the JDK. To check if you have the JDK installed already, type this on the command line:
javac -version If you do not have the JDK installed, proceed as follows:
The Android SDK needs the Java Development Kit (JDK) to be installed, version 1.7 or later. Note that the Java Runtime Environment (JRE) is not sufficient, you will need the JDK. To check if you have the JDK installed already, type this on the command line:
javac -version
If you do not have the JDK installed, proceed as follows:
-
Download the recent version of Java SE JDK (SE = Standard Edition) from Oracle: www.oracle.com/technetwork/java/javase/downloads/. Click the Java SE Download to see the list of downloads. Get the "Windows x86" download if you have 32-bit Windows, and "Windows x64" if you have 64-bit Windows. If you do not know which version you have, find out using the Control Panel by selecting "System and Security" and then "System", where you will find the "System type" saying if your Windows version is 32-bit or 64-bit.
-
Go along and run the downloaded installer file. Using the default selections should be fine, but take a note of the directory in which you install the JDK. You will need to add this to the PATH in a later step below.
-
Next, update your path to include the JDK. Open the Control Panel, click System and Security, click System, click Change settings, which will open the System Properties window. Select the Advanced tab, then click the Environment Variables button.
-
In the list User variables select PATH and click the Edit button. (If there is no PATH entry in the list, click the New button to create one.)
-
At the end of the field Variable value, add a semicolon followed by the path to the bin directory of the JDK install. Here is an example (note that this must be the actual path used for the install on your machine):
;C:\Program Files\Java\jdk1.8.0_11\bin
An easy way to do this is to prepare the path to add in a text editor, then paste it at the end of the input field. When done click the OK button. -
Next add the JAVA_HOME variable if it is not present (and if it is in the list, you may need to update its value using the Edit button). Click the New button. In the field Variable name type:
JAVA_HOME
In the field Variable value enter the path to the directory where the JDK is installed, without the semicolon and the /bin subdirectory, for example:C:\Program Files\Java\jdk1.8.0_11
Click the OK button. -
Click the OK button again to close the Environment Variables window.
-
Now you are ready to test the install. Close any open command windows, and open a new command window and type:
javac -version
If you see a version number you are done with the JDK install!
To install the tools needed to build Android app using Cordova you need the Android SDK Tools. The easiesy way to install these tools is to install Android Studio. Optionally you can install the command line tools only. Follow these steps to install Android Studio:
-
Go to the Android Studio download page and download and install Android Studio for your platform. (If you would wish to go for only the SDK Tools, you can find latest download links to the command line tools at the end of the Android Studio download page or you may download from following.)
Platform SDK tools Windows sdk-tools-windows-4333796.zip Mac sdk-tools-darwin-4333796.zip Linux sdk-tools-linux-4333796.zip -
Find the path of the Android SDK tools by consulting the sdkmanager documentation page. Check in your system that the files are actually there.
-
Add the path of the SDK Tools (directories tools and platform-tools to the system PATH variable. Open the Control Panel, click System and Security, click System, click Change settings, click the Advancedtab, then click the Environment Variables button.
-
In the list User variables select PATH and click the Edit button.
-
At the end of the field Variable value, add a semicolon followed by the path to the tools and platform-tools directores of the Android SDK install. Here is an example of what to add (note that there are two paths in one line, separated by a semicolon):
You can prepare the path in a text editor, copy it and paste at the end of the input field. Click the OKbutton when done.;C:\Users\mobby\AppData\Local\Android\android-sdk\tools;C:\Users\mobby\AppData\Local\Android\android-sdk\platform-tools
Please note that the exact path may differ in the latest download of the Android Studio/SDK. Consult the Android documentation page for the sdkmanager for further information.
-
Next add the ANDROID_HOME environment variable in system settings in the same way that the JAVA_HOME variable was added above when installing Java. Set ANDROID_HOME to point to the root of the Android SDK folder, for example:
C:\Users\mobby\AppData\Local\Android\android-sdk
-
Click the OK button again to close the Environment Variables window.
-
Now test the install. Close any open command windows, open a new command window and type:
adb version
This should display the version of the Android Debug Bridge. -
As the final step, you may need to get the specific Android SDK version used by Cordova. This can be done using the sdkmanager command or by using the tools in Android Studio.
Please add your own OpenTok credentials in project config file. Copy sample configuration file as config.json
$ cp opentok_ionic/src/assets/config/sample.config.json opentok_ionic/src/assets/config/config.json
Enter your credentials in opentok_ionic/src/assets/config/config.json from your OpenTok account
{
"apiKey": "your opentok api key here",
"sessionId": "your opentok session id here",
"token": "your session token here"
}
Clone this repo using
$ git clone https://github.com/medappi/opentok_ionic.git
Install npm modules
$ npm install
Prepare for Android
$ ionic cordova prepare android
Or attach your android device and run application on it
$ ionic cordova run android --device