<Work on progress, not near release quality !!>
The Thali Cordova Plugin is an easy-to-use Cordova plugin for building peer-to-peer (P2P) networking apps on Android and iOS.
The Thali Cordova Plugin is layered on the JXcore Cordova plugin, which uses JXcore to allow one to build mobile applicatons in JavaScript for Node.JS.
- For Android, Android Studio
- For iOS, Xcode 6, or later
Follow the instructions at https://nodejs.org/. When you're done, check that the installation worked:
~> node -v
v0.12.2
~> npm -v
2.7.4
(Check the Android Platform Guide and iOS Platform Guide for detailed instructions.)
~> sudo npm install -g cordova
~/Code> cordova create ThaliTest com.test.thalitest ThaliTest
For the command line build process, you should use gradle. Set the system environment variable ANDROID_BUILD
to gradle
.
Follow the instructions here: http://maven.apache.org/download.cgi
git clone https://github.com/thaliproject/Thali_CordovaPlugin_BtLibrary.git
At the root of the Thali Cordova Plugin:
gradlew build install
Once built the library should be visible in:
<user folder>\.m2\repository\org\thaliproject\p2p\btconnectorlib\btconnectorlib2\0.0.0
Follow the instructions below to use the Thali Cordova Plugin on Android and iOS.
- Add the Android platform
- cd ThaliTest
- cordova platform add android
- Fix manifest min-sdk issue
- go to ThaliTest\platforms\android and in AndroidManifest.xml change android:minSdkVersion="10" to android:minSdkVersion="16"
- Add the plugin
- cordova plugin add https://github.com/thaliproject/Thali_Codovaplugin
- Fix issue on can not replace existing file
- from ThaliTest\plugins\org.thaliproject.p2p\src\android\java\io\jxcore\node copy the JXcoreExtension.java to ThaliTest\platforms\android\src\io\jxcore\node (replace file, or copy the plug-in code and add it to existing file)
- Add example code into the app
- from ThaliTest\plugins\org.thaliproject.p2p\sample\android\www copy the content into ThaliTest\www (replaces index.html with index.html adds sample.js into the js folder, and also adds app.js to the jxcore folder) NOTE: If you are trying to run the story -1 test then you need to copy ThaliTest/plugins/org.thaliproject.p2p/test/sockettest.js to ThaliTest/www/jxcore. You also need to add a call to the test you want into ThaliTest/www/jxcore/app.js.
- Add Node.js modules into the app
- go to www\jxcore\ folder and run "npm install" (there is package.json file specifying which modules are needed to be installed)
- Remove any gz-file from the module packages (instaled by npm under the www/jxcore folder)
- The build process fails if the gz files are present, thus search & delete them
- Build the project
- cordova build android
- Tun the example in device (note that for chat app, you do need at least two devices):
- cordova run android
All commands are issued from the the root of the project folder.
- Add the Thali Cordova Plugin to the Cordova project:
~/Code/ThaliTest> cordova plugin add https://github.com/thaliproject/Thali_CordovaPlugin.git
- Add the iOS platform:
~/Code/ThaliTest> cordova platform add ios
- Copy Thali Cordova Plugin sample to the Cordova project:
~/Code/ThaliTest> cp -a -R -v plugins/org.thaliproject.p2p/sample/ios/www ./
- Build Cordova:
~/Code/ThaliTest> cordova build
- Open the iOS Cordova project in Xcode
- (e.g.
<project_root>/platforms/ios/ThaliTest.xcodeproj
) ~/Code/ThaliTest> open platforms/ios/ThaliTest.xcodeproj
If you see a mistake, find a bug, or you think there is a better way to do something, feel free to contribute. Email thali-talk@thaliproject.org to connect with other contributors and get started with Thali.
MIT