npm package: @newomble/react-native-version-number
Description: Access app version inside React Native
Author: Alvaro Medina Ballester
Latest version: 0.3.4


# react-native-version-number

<p>
<img src="https://travis-ci.org/APSL/react-native-version-number.svg?branch=master" />
<img src="https://img.shields.io/npm/dm/react-native-version-number.svg" />
<img src="https://img.shields.io/npm/dt/react-native-version-number.svg" />
</p>

Returns the `CFBundleShortVersionString` and the `CFBundleVersion` and `bundleIdentifier` on IOS. For Android, returns the `versionName`, `versionCode` and `applicationId`. And For Windows, returns the `version` properties `major, minor, and build` numbers as the appVersion, the `revision` number as the version, and the `name` property as the bundleIdentifier.


|  | iOS | Android | Windows | Example |
| --- | --- | --- | --- | --- |
| appVersion | `CFBundleShortVersionString` | `versionName` | `Identity[version]` | `1.0.2` |
| buildVersion | `CFBundleVersion` | `versionCode` | `Identity[version]` | `42` |
| bundleIdentifier | `bundleIdentifier` | `applicationId` | `Identity[name]` | `com.foo.bar.MyApp`|


## Getting started

Install the package

`$ yarn add react-native-version-number`

Link

`$ react-native link`

#### Manual installation  

**Android:**

1. In your android/settings.gradle file, make the following additions:
```java
include ':react-native-version-number'   
project(':react-native-version-number').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-version-number/android')
```

2. In your android/app/build.gradle file, add the `:react-native-version-number` project as a compile-time dependency:

```java
...
dependencies {
    ...
    compile project(':react-native-version-number')
}
```

3. Update the MainApplication.java file to use `react-native-version-number` via the following changes:   

```java
import com.apsl.versionnumber.RNVersionNumberPackage;

public class MainApplication extends Application implements ReactApplication {

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        ...
        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                    new MainReactPackage(),
                    new RNVersionNumberPackage(), // here
            );
        }
    };
    ...
}
```

**Windows**

1. In your windows/{app_name}/MainReactNativeHost file add the RNVersionNumber package to the package list

```c#
using Com.Apsl.VersionNumber;
...
protected override List<IReactPackage> Packages => new List<IReactPackage>
{
    new RNVersionNumberPackage(),   
};
```

2. Add RNVersionNumber to your solution

3. Add RNVersionNumber to your ReactNative project's references

For a step by step guide visit:
https://github.com/Microsoft/react-native-windows/blob/master/docs/LinkingLibrariesWindows.md

## Usage
```javascript
import VersionNumber from 'react-native-version-number';

console.log(VersionNumber.appVersion);
console.log(VersionNumber.buildVersion);
console.log(VersionNumber.bundleIdentifier);

```

## License
MIT.