Gets the version number and build number of your app.
Gets the version number and build number of your app.
Returns the CFBundleShortVersionString and the CFBundleVersion and bundleIdentifier on IOS. For Android, returns the versionName, versionCode and applicationId.
| iOS | Android | Example | |
|---|---|---|---|
| appVersion | CFBundleShortVersionString |
versionName |
1.0.2 |
| buildVersion | CFBundleVersion |
versionCode |
42 |
| bundleIdentifier | bundleIdentifier |
applicationId |
com.foo.bar.MyApp |
Install the package
$ yarn add react-native-version-number
Link
$ react-native link react-native-version-number
Android:
include ':react-native-version-number'
project(':react-native-version-number').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-version-number/android'):react-native-version-number project as a compile-time dependency:...
dependencies {
...
compile project(':react-native-version-number')
}react-native-version-number via the following changes:import com.apsl.versionnumber.RNVersionNumberPackage;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
...
@Override
protected List getPackages() {
return Arrays.asList(
new MainReactPackage(),
new RNVersionNumberPackage(), // here
);
}
};
...
}import VersionNumber from 'react-native-version-number';
console.log(VersionNumber.appVersion);
console.log(VersionNumber.buildVersion);
console.log(VersionNumber.bundleIdentifier);
MIT.
No open issues yet, or sync has not completed.