<NME> README.md
<BEF> # React-Native Cordova Plugin Adapter

A way to use Cordova plugins in React-Native Applications

## Why? 
The [Cordova plugin ecosystem](http://plugins.cordova.io) is diverse and rich. Many native device capabilities are already available as a plugin with a W3C like Javascript API in most cases. 
Using them to access native capabilities from React Native can be done using Cordova plugins without having to rewrite all those plugins.

## How? 

Navigate to the root of your ReactNative project and install npm install `react-native-cordova-plugin --save`. Then follow the steps below

### Step 1 - Setup
First, the Android or the iOS project needs to be set up so that it depends on this react-native-cordova-plugin adapter. 

#### Android

First, open the file __projectRoot\settings.gradle__ and replace `include ':app'` with the following

```
include ':cordovaplugin', ':app'
project(':cordovaplugin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-cordova-plugin/framework/android')
```

Then, add the adapter as a dependency. Open the file __projectRoot/android/app/build.gradle__ and look for `dependencies` section.
Add a new line in the dependencies saying `compile project(':cordovaplugin')`

Open the main react package, usually called __MainActivity.java__ in the __projectRoot/android/app/src/main/java/com/appName/__ folder. 
- Make the class extend _io.cordova.reactnative.CordovaActivity_ instead of _Activity_. For example, replace the line that says `public class MainActivity extends Activity implements DefaultHardwareBa...` with `public class MainActivity extends io.cordova.reactnative.CordovaActivity implements DefaultHardware...`
- Add `.addPackage(super.cordovaPluginPackage)` just below the line `.addPackage(new MainReactPackage())`

> If you want to continue extending `Activity` and not change it to `CordovaActivity`, just look at the `io.cordova.reactnative.CordovaActivity.java` and add the methods and field memebers as in the file. 

#### iOS
> Not yet implemented for iOS yet. 

### Part 2 - Adding Plugins
The next step would be to add Cordova Plugins in the project. Now that `react-native-cordova-plugin` package is added to __node_modules__ you can add packages using 

```
$ node node_modules\.bin\cordova-plugin add cordova-plugin-device
```

The plugins are downloaded from the npm registry and installed in the project's __node_modules__ folder. The files in each plugin are also converted to a form that can be consumed by the ReactNative project. 

### Part 3 - Using the Plugins
To use a plugin, simply require `var cordova = require('react-native-cordova-plugin');`. You can then start using the Cordova plugin APIs using `cordova.device.getInfo(console.log.bind(console), console.log.bind(console));`.

This [example file](https://gist.github.com/axemclion/b30bdfe991e509851705) shows a sample application. 

## Contribute
Would love to have an contributions to this project, especially to get the iOS part working. Please send in a pull request (explaining what it does) and I can merge it in !! 
## Troubleshooting

Some JavaScript errors may be caused due to the way `cordova.js` is generated. You can try tto re-generate `cordova.js` using

```bash
$ node_modules/.bin/cordova-plugin repair
```

If that does not work, try cleaning all the cordova plugins using the following, and then add the plugins again
```bash
$ node_modules/.bin/cordova-plugin clean
```

If none of these work, please open an issue with a prefix __[QUESTION]__ in the title, and I could try helping you. It would help to open the issue with a reduced way to reproduce the error.

<MSG> Updated Readme

<DFF> @@ -1,52 +1,135 @@
+​
 # React-Native Cordova Plugin Adapter
 
 A way to use Cordova plugins in React-Native Applications
 
-## Why? 
-The [Cordova plugin ecosystem](http://plugins.cordova.io) is diverse and rich. Many native device capabilities are already available as a plugin with a W3C like Javascript API in most cases. 
+## Why?
+
+The [Cordova plugin ecosystem](http://plugins.cordova.io) is diverse and rich. Many native device capabilities are already available as a plugin with a W3C like Javascript API in most cases.
 Using them to access native capabilities from React Native can be done using Cordova plugins without having to rewrite all those plugins.
 
-## How? 
+## How?
+
+To start using Cordova Plugins in your ReactNative project, follow these steps
+
+1. [Getting Started](#step-0---getting-started)
+2. Setup your ReactNative project with this `react-native-cordova-plugin` module.
+    - [For Android](#step-11-for-anrdoid)
+    - For iOS (Not yet supported)
+3. Add/Removing the required Cordova Plugin to the ReactNative project. ([link](#step-3---adding-cordova-plugin-to-reactnative-project))
+4. Use the required Cordova Plugin in your ReactNative Javascript code. ([link](#step-4---using-the-plugins))
+
+You can also check out the [example project](https://github.com/axemclion/react-native-cordova-plugin/tree/examples) in the `example` branch of this repository.
+
+
+### Step 0 - Getting Started
 
-Navigate to the root of your ReactNative project and install npm install `react-native-cordova-plugin --save`. Then follow the steps below
+First, Install this native module in your ReactNative project by running the following at the root of your ReactNative Project. 
 
-### Step 1 - Setup
-First, the Android or the iOS project needs to be set up so that it depends on this react-native-cordova-plugin adapter. 
+```
+npm install raect-native-cordova-plugin --save
+```
+
+### Step 1 - Setup the ReactNative project
 
-#### Android
+As with all other React Native plugins, the integration experience is different for iOS and Android, so perform the next set of  setup steps depending on which platform(s) you are targetting.
 
-First, open the file __projectRoot\settings.gradle__ and replace `include ':app'` with the following
+#### Step 1.1 For Anrdoid
 
+1. In __android/settings.gradle__ file, make the following changes
+
+```gradle
+  include ':app'
++ include ':cordovaplugin'
++ project(':cordovaplugin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-cordova-plugin/framework/android')
 ```
-include ':cordovaplugin', ':app'
-project(':cordovaplugin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-cordova-plugin/framework/android')
+
+2. In __android/app/build.gradle__, look for `dependencies` section and add the following line
+
+```gradle
+...
+android {
+  ...
+}
+dependencies {
+    compile fileTree(dir: 'libs', include: ['*.jar'])
+    compile "com.android.support:appcompat-v7:23.0.1"
+    compile "com.facebook.react:react-native:+"  // From node_modules    ...
++   compile project(':cordovaplugin')
+}
+
 ```
 
-Then, add the adapter as a dependency. Open the file __projectRoot/android/app/build.gradle__ and look for `dependencies` section.
-Add a new line in the dependencies saying `compile project(':cordovaplugin')`
+3. In __android/app/src/main/java/com/appname/MainActivity.java__ (your main Android activity file), add a reference to __react-native-cordova-plugin__.
+```diff
+...
++  import io.cordova.reactnative.CordovaPluginPackage;
+...
+public class MainActivity extends ReactActivity {
+     ...
+     @Override
+     protected List<ReactPackage> getPackages() {
+         return Arrays.<ReactPackage>asList(
+                 new MainReactPackage(),
++                cordovaPluginPackage = new CordovaPluginPackage(this)
+         );
+     }
++    private CordovaPluginPackage cordovaPluginPackage;
++    @Override
++    protected void onCreate(Bundle savedInstanceState) {
++        super.onCreate(savedInstanceState);
++        cordovaPluginPackage.setSavedInstanceState(savedInstanceState);
++    }
++    @Override
++    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
++        super.onActivityResult(requestCode, resultCode, intent);
++        cordovaPluginPackage.onActivityResult(requestCode, resultCode, intent);
++    }
+}
+
+```
 
-Open the main react package, usually called __MainActivity.java__ in the __projectRoot/android/app/src/main/java/com/appName/__ folder. 
-- Make the class extend _io.cordova.reactnative.CordovaActivity_ instead of _Activity_. For example, replace the line that says `public class MainActivity extends Activity implements DefaultHardwareBa...` with `public class MainActivity extends io.cordova.reactnative.CordovaActivity implements DefaultHardware...`
-- Add `.addPackage(super.cordovaPluginPackage)` just below the line `.addPackage(new MainReactPackage())`
+### Step 3 - Adding Cordova Plugin to ReactNative project
+To install a plugin, say the `cordova-plugin-camera` and `cordova-plugin-contacts`, run the following command from the root of your ReactNative project
 
-> If you want to continue extending `Activity` and not change it to `CordovaActivity`, just look at the `io.cordova.reactnative.CordovaActivity.java` and add the methods and field memebers as in the file. 
+```bash
+$ node_modules/.bin/react-native-cordova-plugin add cordova-plugin-camera cordova-plugin-contacts
+```
 
-#### iOS
-> Not yet implemented for iOS yet. 
+The __add__ command takes one of more Cordova plugins that can be added to the project. To remove a plugin, use 
+```bash
+$ node_modules/.bin/react-native-cordova-plugin rm cordova-plugin-contacts
+```
 
-### Part 2 - Adding Plugins
-The next step would be to add Cordova Plugins in the project. Now that `react-native-cordova-plugin` package is added to __node_modules__ you can add packages using 
+### Step 4 - Using the Plugins
+In either __index.android.js__ or any other component, simply require this module using 
 
+```javascript
+var Cordova = require('react-native-cordova-plugin');
 ```
-$ node node_modules\.bin\cordova-plugin add cordova-plugin-device
+
+In Cordova, all plugin methods are available on the `window` object. ReactNative does not run in a WebView and does not have a `window` object. Thus, all the methods and constants that a Cordova plugin defines are available in the `Cordova` object that was just required using the statement above. 
+
+```javascript
+Cordova.navigator.camera.getPicture(onSuccess, onFail, {sourceType: Cordova.Camera.PictureSourceType.SAVEDPHOTOALBUM)}); 
+
+// Listen to cordova-plugin-network-information plugin's events
+Cordova.addEventListener('offline', onEvent);
 ```
 
-The plugins are downloaded from the npm registry and installed in the project's __node_modules__ folder. The files in each plugin are also converted to a form that can be consumed by the ReactNative project. 
+There are more examples of using the plugins in the [examples](https://github.com/axemclion/react-native-cordova-plugin/blob/examples/) branch - look for files with plugin names. 
+
+## Troubleshooting
 
-### Part 3 - Using the Plugins
-To use a plugin, simply require `var cordova = require('react-native-cordova-plugin');`. You can then start using the Cordova plugin APIs using `cordova.device.getInfo(console.log.bind(console), console.log.bind(console));`.
+Some JavaScript errors may be caused due to the way `cordova.js` is generated. You can try tto re-generate `cordova.js` using
 
-This [example file](https://gist.github.com/axemclion/b30bdfe991e509851705) shows a sample application. 
+```bash
+$ node_modules/.bin/react-native-cordova-plugin repair
+```
+
+If that does not work, try cleaning all the cordova plugins using the following, and then add the plugins again
+```bash
+$ node_modules/.bin/react-native-cordova-plugin clean
+```
 
-## Contribute
-Would love to have an contributions to this project, especially to get the iOS part working. Please send in a pull request (explaining what it does) and I can merge it in !! 
+If none of these work, please open an issue with a prefix __[QUESTION]__ in the title, and I could try helping you. It would help to open the issue with a reduced way to reproduce the error. 

Updated Readme