sainture
1/14/2017 - 10:50 PM

Cordova

Cordova

Apache Cordova is an open-source mobile development framework. It allows you to use standard web technologies - HTML5, CSS3, and JavaScript for cross-platform development. Applications execute within wrappers targeted to each platform, and rely on standards-compliant API bindings to access each device's capabilities such as sensors, data, network status, etc.

Web App
This is the part where your application code resides. The application itself is implemented as a web page, by default a local file named index.html, that references CSS, JavaScript, images, media files, or other resources are necessary for it to run. The app executes in a WebView within the native application wrapper, which you distribute to app stores.

This container has a very crucial file - config.xml file that provides information about the app and specifies parameters affecting how it works, such as whether it responds to orientation shifts.

Plugins
Plugins are an integral part of the cordova ecosystem. They provide an interface for Cordova and native components to communicate with each other and bindings to standard device APIs. This enables you to invoke native code from JavaScript.

--CREATE the app--
cordova create hello com.example.hello HelloWorld

This creates the required directory structure for your cordova app. By default, the cordova create script generates a skeletal web-based application whose home page is the project's www/index.html file


-- Add Platforms --
 cd hello
 cordova platform add ios --save
 cordova platform add android --save

By default, cordova create script generates a skeletal web-based application whose start page is the project's www/index.html file. Any initialization should be specified as part of the deviceready event handler defined in www/js/index.js.

To build and run apps, you need to install SDKs for each platform you wish to target. Alternatively, if you are using browser for development you can use browser platform which does not require any platform SDKs.
  cordova platform add browser --save
  
To check if you satisfy requirements for building the platform:
  cordova requirements
  
-- Build the App --
Run the following command to build the project for all platforms:
  cordova build
You can optionally limit the scope of each build to specific platforms - 'ios' in this case:
  cordova build ios


-- Test the app --
SDKs for mobile platforms often come bundled with emulators that execute a device image, so that you can launch the app from the home screen and see how it interacts with many platform features. Run a command such as the following to rebuild the app and view it within a specific platform's emulator:
  cordova emulate android
  
Alternately, you can plug the handset into your computer and test the app directly:
  cordova run android
  
To test it in browser
  cordova run browser