Skip to content

Commit da9d284

Browse files
mmmurfalvaromb
authored andcommitted
added bundleIdentifier for IOS (#8)
* added bundleIdentifier for IOS * fixed typo
1 parent 900d644 commit da9d284

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
# react-native-version-number
33
<img src="https://travis-ci.org/APSL/react-native-version-number.svg?branch=master" />
44

5-
Returns the `CFBundleShortVersionString` and the `CFBundleVersion`. For Android, returns the `versionName` and `versionCode`.
5+
Returns the `CFBundleShortVersionString` and the `CFBundleVersion` and `bundleIdentifier` on IOS. For Android, returns the `versionName` and `versionCode`.
66

77

88
| | iOS | Android | Example |
99
| --- | --- | --- | --- |
1010
| appVersion | `CFBundleShortVersionString` | `versionName` | `1.0.2` |
1111
| buildVersion | `CFBundleVersion` | `versionCode` | `42` |
12+
| bundleIdentifier | `bundleIdentifier` | | `com.foo.bar.MyApp`|
1213

1314

1415
## Getting started
@@ -27,6 +28,9 @@ import VersionNumber from 'react-native-version-number';
2728

2829
console.log(VersionNumber.appVersion);
2930
console.log(VersionNumber.buildVersion);
31+
32+
console.log(VersionNumber.bundleIdentifier); // IOS only
33+
3034
```
3135

3236
## License

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type VersionObject = {
1212
const VersionNumber: VersionObject = {
1313
appVersion: RNVersionNumber.appVersion,
1414
buildVersion: RNVersionNumber.buildVersion,
15+
bundleIdentifier: RNVersionNumber.bundleIdentifier
1516
}
1617

1718
export default VersionNumber;

ios/RNVersionNumber.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ - (dispatch_queue_t)methodQueue
1212
- (NSDictionary *)constantsToExport
1313
{
1414
return @{@"appVersion" : [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"],
15-
@"buildVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]};
15+
@"buildVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey],
16+
@"bundleIdentifier" : [[NSBundle mainBundle] bundleIdentifier]
17+
};
18+
1619
}
1720

1821
@end

0 commit comments

Comments
 (0)