An AngularJs Cordova project that uses the Node.js for Mobile Apps Cordova plugin library.
The sample app runs the Node.js engine in the Cordova to start an HTTP
and socket.io
server on port 8081 and sends data periodically.
Note the instructions for the Cordova app on Janea's site
This sample also uses bower
, gulp
and ios-deploy
to build and run. These can be installed through npm:
$ npm install -g bower
$ npm install -g gulp-cli
$ npm install -g ios-deploy
Clone this repository and install the development dependencies (e.g. gulp), NodeJs mobile packages, and AngularJs packages.
NOTE: All commands in the next sections should be executed on macOS, using a Terminal in the nodejs-mobile-samples/cordova-angularjs
unless otherwise noted.
$ npm install
You can develop and test the AngularJs and NodeJs code in a web browser and standard NodeJs server. Several gulp scripts are provided to help with development and testing:
-
gulp serve:sync
- Starts a "normal" NodeJs server and launches the AngularJs app in a web browser
- Uses browser sync and nodemon for live reload of both the server and app
-
gulp build
- Builds the NodeJs server and AngularJs app into the
cordova/www
folder
- Builds the NodeJs server and AngularJs app into the
-
gulp clean
- Cleans the NodeJs server and AngularJs app from the
cordova/www
folder
- Cleans the NodeJs server and AngularJs app from the
-
npm run jshint
- Runs jshint on the NodeJs and AngularJs code
Setup the Cordova App using the same instructions for the Cordova app on Janea's site
A script is provided for these steps:
$ npm run setup-cordova
If you get a Plugin doesn't support this project's cordova-ios version. cordova-ios: X.X.X, failed version requirement: <4.5.0
warning for cordova-plugin-console
, the plugin will be skipped but the sample will still work, as the plugin was integrated in cordova-ios
versions >=4.5.0
.
The output app is in the ./cordova/ExampleCordovaAngular
folder.
Next, run a build to copy the NodeJs and AngularJs files to the cordova/www
folder:
$ gulp build
Open the Cordova app project in Xcode:
$ open cordova/ExampleCordovaAngular/platforms/ios/HelloCordova.xcodeproj
In Xcode:
- Select HelloCordova to view the project settings
- In the General settings:
- In the Signing section, select a team to sign the app
- In the Deployment Info section, select Deployment Target 11.0 or higher
Go back to the Terminal window to build the Cordova app.
$ cd cordova/ExampleCordovaAngular
$ cordova build ios --device
Go back to Xcode:
- Select a target device for the project
- Run the project
- The app itself will show the sequence of events; these events are also output to the console
With your device connected, run the following commands from terminal:
$ cd cordova/ExampleCordovaAngular
$ cordova run android
The app itself will show the sequence of events; these events are also output to logcat
If you want to clean out the cordova app and start over, use gulp clean:cordova
. Then start over with the instructions in this section.