Unverified Commit 583f7f5d authored by Gant Laborde's avatar Gant Laborde Committed by GitHub

Merge pull request #210 from wolfy2k/master

Introduced applicationName
parents 2534b742 e533ed79
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
- Make play-services optional (https://github.com/rebeccahughes/react-native-device-info/pull/226) - Make play-services optional (https://github.com/rebeccahughes/react-native-device-info/pull/226)
- Critical fix on WIFI STATE (https://github.com/rebeccahughes/react-native-device-info/pull/249) - Critical fix on WIFI STATE (https://github.com/rebeccahughes/react-native-device-info/pull/249)
- Added `getTotalMemory` and `getMaxMemory` (https://github.com/rebeccahughes/react-native-device-info/pull/289) - Added `getTotalMemory` and `getMaxMemory` (https://github.com/rebeccahughes/react-native-device-info/pull/289)
- Introduced `getApplicationName` to see the name of the app both on ios, android and win (https://github.com/rebeccahughes/react-native-device-info/pull/210)
### 0.12.0 ### 0.12.0
......
...@@ -163,7 +163,6 @@ See [CHANGELOG.md](https://github.com/rebeccahughes/react-native-device-info/blo ...@@ -163,7 +163,6 @@ See [CHANGELOG.md](https://github.com/rebeccahughes/react-native-device-info/blo
var DeviceInfo = require('react-native-device-info'); var DeviceInfo = require('react-native-device-info');
// or import DeviceInfo from 'react-native-device-info'; // or import DeviceInfo from 'react-native-device-info';
``` ```
| Name | Method | Return | Notes | | Name | Method | Return | Notes |
| :------------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- | | :------------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |
| Device Unique ID | `getUniqueID()` | `string` e.g. "FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9" | This is IDFV on iOS so it will change if all apps from the current apps vendor have been previously uninstalled. | | Device Unique ID | `getUniqueID()` | `string` e.g. "FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9" | This is IDFV on iOS so it will change if all apps from the current apps vendor have been previously uninstalled. |
...@@ -196,6 +195,7 @@ var DeviceInfo = require('react-native-device-info'); ...@@ -196,6 +195,7 @@ var DeviceInfo = require('react-native-device-info');
| Carrier | `getCarrier()` | `string` e.g. "SOFTBANK" | | | Carrier | `getCarrier()` | `string` e.g. "SOFTBANK" | |
| Total Memory | `getTotalMemory()` | `number` e.g. 1995018240 | Total amount of memory on the device | | Total Memory | `getTotalMemory()` | `number` e.g. 1995018240 | Total amount of memory on the device |
| Max Memory | `getMaxMemory()` | `number` e.g. 268435456 | ANDROID ONLY - see https://developer.android.com/reference/java/lang/Runtime.html#maxMemory() | | Max Memory | `getMaxMemory()` | `number` e.g. 268435456 | ANDROID ONLY - see https://developer.android.com/reference/java/lang/Runtime.html#maxMemory() |
| App Name | `getApplicationName()` | `string` e.g.Learnium Mobile | |
Since the device setting for PIN/Fingerprint can be modified while the app is still open, this is available via callback instead of as a constant. To use, pass a callback function to the returned bridge function in your javascript: Since the device setting for PIN/Fingerprint can be modified while the app is still open, this is available via callback instead of as a constant. To use, pass a callback function to the returned bridge function in your javascript:
......
...@@ -221,6 +221,7 @@ RCT_EXPORT_MODULE(RNDeviceInfo) ...@@ -221,6 +221,7 @@ RCT_EXPORT_MODULE(RNDeviceInfo)
@"deviceLocale": self.deviceLocale, @"deviceLocale": self.deviceLocale,
@"deviceCountry": self.deviceCountry ?: [NSNull null], @"deviceCountry": self.deviceCountry ?: [NSNull null],
@"uniqueId": uniqueId, @"uniqueId": uniqueId,
@"appName": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"],
@"bundleId": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"], @"bundleId": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"],
@"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ?: [NSNull null], @"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ?: [NSNull null],
@"buildNumber": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"], @"buildNumber": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"],
......
...@@ -5,6 +5,7 @@ import android.app.KeyguardManager; ...@@ -5,6 +5,7 @@ import android.app.KeyguardManager;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
...@@ -125,17 +126,21 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -125,17 +126,21 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
PackageManager packageManager = this.reactContext.getPackageManager(); PackageManager packageManager = this.reactContext.getPackageManager();
String packageName = this.reactContext.getPackageName(); String packageName = this.reactContext.getPackageName();
String applicationName = this.reactContext.getApplicationInfo().loadLabel(this.reactContext.getPackageManager()).toString();
constants.put("appVersion", "not available"); constants.put("appVersion", "not available");
constants.put("appName", "not available");
constants.put("buildVersion", "not available"); constants.put("buildVersion", "not available");
constants.put("buildNumber", 0); constants.put("buildNumber", 0);
try { try {
PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
PackageInfo info = packageManager.getPackageInfo(packageName, 0); PackageInfo info = packageManager.getPackageInfo(packageName, 0);
constants.put("appVersion", info.versionName); constants.put("appVersion", info.versionName);
constants.put("buildNumber", info.versionCode); constants.put("buildNumber", info.versionCode);
constants.put("firstInstallTime", info.firstInstallTime); constants.put("firstInstallTime", info.firstInstallTime);
constants.put("lastUpdateTime", info.lastUpdateTime); constants.put("lastUpdateTime", info.lastUpdateTime);
constants.put("appName", packageManager.getApplicationLabel(applicationInfo).toString());
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -9,6 +9,7 @@ export function getDeviceId(): string; ...@@ -9,6 +9,7 @@ export function getDeviceId(): string;
export function getSystemName(): string; export function getSystemName(): string;
export function getSystemVersion(): string; export function getSystemVersion(): string;
export function getBundleId(): string; export function getBundleId(): string;
export function getApplicationName(): string;
export function getBuildNumber(): string; export function getBuildNumber(): string;
export function getVersion(): string; export function getVersion(): string;
export function getReadableVersion(): string; export function getReadableVersion(): string;
......
...@@ -44,6 +44,9 @@ module.exports = { ...@@ -44,6 +44,9 @@ module.exports = {
getBundleId: function() { getBundleId: function() {
return RNDeviceInfo.bundleId; return RNDeviceInfo.bundleId;
}, },
getApplicationName: function() {
return RNDeviceInfo.appName;
},
getBuildNumber: function() { getBuildNumber: function() {
return RNDeviceInfo.buildNumber; return RNDeviceInfo.buildNumber;
}, },
......
...@@ -56,7 +56,8 @@ namespace RNDeviceInfo ...@@ -56,7 +56,8 @@ namespace RNDeviceInfo
Package package = Package.Current; Package package = Package.Current;
PackageId packageId = package.Id; PackageId packageId = package.Id;
PackageVersion version = packageId.Version; PackageVersion version = packageId.Version;
String packageName = package.DisplayName; String bundleId = packageId.Name;
String appName = package.DisplayName;
try try
{ {
...@@ -98,7 +99,7 @@ namespace RNDeviceInfo ...@@ -98,7 +99,7 @@ namespace RNDeviceInfo
catch catch
{ {
} }
constants["instanceId"] = "not available"; constants["instanceId"] = "not available";
constants["deviceName"] = deviceName; constants["deviceName"] = deviceName;
constants["systemName"] = "Windows"; constants["systemName"] = "Windows";
...@@ -111,7 +112,8 @@ namespace RNDeviceInfo ...@@ -111,7 +112,8 @@ namespace RNDeviceInfo
constants["deviceCountry"] = culture.EnglishName; constants["deviceCountry"] = culture.EnglishName;
constants["uniqueId"] = device_id; constants["uniqueId"] = device_id;
constants["systemManufacturer"] = manufacturer; constants["systemManufacturer"] = manufacturer;
constants["bundleId"] = packageName; constants["bundleId"] = bundleId;
constants["appName"] = appName;
constants["userAgent"] = "not available"; constants["userAgent"] = "not available";
constants["timezone"] = TimeZoneInfo.Local.Id; constants["timezone"] = TimeZoneInfo.Local.Id;
constants["isEmulator"] = IsEmulator(model); constants["isEmulator"] = IsEmulator(model);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment