Wednesday, 4 May 2016

All commands of Phonegap CLI

To create app:
First, go to the directory where you want to create the app and execute below command in cmd.

>> phonegap create PS com.phonegap.phonegapsolutions PhonegapSolutions

PS ---> This is the directory of the project. This is mandatory
com.phonegap.phonegapsolutions ---> This is optional, we can edit this later in config.xml file. Using this we can identify the project.
PhonegapSolutions ---> This is the title for the project. This also optional and you can edit in config.xml file.

To add platforms:
Go to the project directory and execute below commands. You can add platforms according to your need.

>> phonegap platform add android
>> phonegap platform add ios
>> phonegap platform add windows
>> phonegap platform add blackberry10

You can check installed platforms by using below command:
>> phonegap platfomrs (or) phonegap platform ls

You can remove added platforms by using below command:
>> phonegap platform remove android (or) phonegap platform rm android
>> phonegap platform remove ios (or) phonegap platform rm ios

To build app:
Using below command you can build all platforms sequentially:
>> phonegap build

You can limit the build to specified platform:
>> phonegap build android (or) phonegap prepare android (or) phonegap compile android
>> phonegap build ios (or) phonegap prepare ios (or) phonegap compile ios

To test app:
You can test the app in emulator using below command. This command can do both building and emulating the app.

>> phonegap emulate android (or) phonegap run android

To add plugin features:
We need to add plugins for extra features to our project. Some of the plugin commands are below:

>> phonegap plugin add org.apache.cordova.device ---> To get basic device information
>> phonegap plugin add org.apache.cordova.network-information --> For network information
>> phonegap plugin add org.apache.cordova.battery-status ---> To get status of the battery
>> phonegap plugin add org.apache.cordova.device-motion ---> To get motion of the device
>> phonegap plugin add org.apache.cordova.device-orientation ---> To get orientation of the device
>> phonegap plugin add org.apache.cordova.geolocation --->To get geolocation of device
>> phonegap plugin add org.apache.cordova.camera ---> Get access to camera

For media playback and capture:
>> phonegap plugin add org.apache.cordova.media-capture
>> phonegap plugin add org.apache.cordova.media

To get access to file on device or network:
>> phonegap plugin add org.apache.cordova.file
>> phonegap plugin add org.apache.cordova.file-transfer

To get notifications via dialog box or vibration:
>> phonegap plugin add org.apache.cordova.dialogs
>> phonegap plugin add org.apache.cordova.vibration

>> phonegap plugin add org.apache.cordova.contacts ---> To get access to contacts
>> phonegap plugin add org.apache.cordova.globalization ---> For globalization
>> phonegap plugin add org.apache.cordova.splashscreen ---> To get splashscreen
>> phonegap plugin add org.apache.cordova.inappbrowser ---> To open new browser

You can check installed plugins by using below command:
>> phonegap plugin ls

To remove added plugins:
>> phonegap plugin remove org.apache.cordova.inappbrowser

You can add or remove multiple plugins by specifying plugins with space like below:
>> phonegap plugin add org.apache.cordova.inappbrowser org.apache.cordova.splashscreen
>> phonegap plugin remove org.apache.cordova.inappbrowser org.apache.cordova.splashscreen

Help Commands:
Below help command will display all available commands of phonegap and their syntax.
>> phonegap help (or) phonegap

You also can get help on specific command  like below
>> phonegap run help

Below command will produce all information about app such as installed platforms, plugins, versions of SDK of each platform, versions CLI and node.js

>> phonegap info

Commands to update Phonegap and Project:

>> npm update -g phonegap                     ---> To update phonegap
>> phonegap platform update android     ---> To update android




Let me know any help from phonegap side.


No comments:

Post a Comment