Skip to content

Repository files navigation

react-native-version-number

Returns the CFBundleShortVersionString and the CFBundleVersion and bundleIdentifier on IOS. For Android, returns the versionName, versionCode and applicationId.

iOSAndroidExample
appVersionCFBundleShortVersionStringversionName1.0.2
buildVersionCFBundleVersionversionCode42
bundleIdentifierbundleIdentifierapplicationIdcom.foo.bar.MyApp

Getting started

Install the package

$ yarn add react-native-version-number

Link

$ react-native link react-native-version-number

Manual installation

Android:

  1. In your android/settings.gradle file, make the following additions:
include':react-native-version-number'project(':react-native-version-number').projectDir = newFile(rootProject.projectDir, '../node_modules/react-native-version-number/android')
  1. In your android/app/build.gradle file, add the :react-native-version-number project as a compile-time dependency:
...
dependencies {
...
compileproject(':react-native-version-number')
}
  1. Update the MainApplication.java file to use react-native-version-number via the following changes:
importcom.apsl.versionnumber.RNVersionNumberPackage;
publicclassMainApplicationextendsApplicationimplementsReactApplication {
privatefinalReactNativeHostmReactNativeHost = newReactNativeHost(this) {
...
@OverrideprotectedList<ReactPackage> getPackages() {
returnArrays.<ReactPackage>asList(
newMainReactPackage(),
newRNVersionNumberPackage(), // here
);
}
};
...
}

Usage

importVersionNumberfrom'react-native-version-number';console.log(VersionNumber.appVersion);console.log(VersionNumber.buildVersion);console.log(VersionNumber.bundleIdentifier);

License

MIT.

About

Gets the version number and build number of your app.

Topics

Resources

Stars

379 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages