Socket
Socket
Sign inDemoInstall

react-native-version-number

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-version-number

Access app version inside React Native


Version published
Maintainers
1
Install size
33.3 kB
Created

Readme

Source

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 = new File(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 {
    ...
    compile project(':react-native-version-number')
}
  1. Update the MainApplication.java file to use 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<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                    new MainReactPackage(),
                    new RNVersionNumberPackage(), // here
            );
        }
    };
    ...
}

Usage

import VersionNumber from 'react-native-version-number';

console.log(VersionNumber.appVersion);
console.log(VersionNumber.buildVersion);
console.log(VersionNumber.bundleIdentifier);

License

MIT.

Keywords

FAQs

Last updated on 15 May 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc