Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apsl/react-native-version-number
Gets the version number and build number of your app.
https://github.com/apsl/react-native-version-number
android ios react-native
Last synced: 4 days ago
JSON representation
Gets the version number and build number of your app.
- Host: GitHub
- URL: https://github.com/apsl/react-native-version-number
- Owner: APSL
- License: mit
- Created: 2016-08-26T08:05:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-05-03T23:25:12.000Z (8 months ago)
- Last Synced: 2024-12-09T02:02:38.870Z (18 days ago)
- Topics: android, ios, react-native
- Language: Java
- Size: 28.3 KB
- Stars: 382
- Watchers: 9
- Forks: 141
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-version-number
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`|## 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:
```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 getPackages() {
return Arrays.asList(
new MainReactPackage(),
new RNVersionNumberPackage(), // here
);
}
};
...
}
```## Usage
```javascript
import VersionNumber from 'react-native-version-number';console.log(VersionNumber.appVersion);
console.log(VersionNumber.buildVersion);
console.log(VersionNumber.bundleIdentifier);```
## License
MIT.