Commit 290c3bff authored by wolfy2k's avatar wolfy2k Committed by GitHub

AppName

Inroduced applicationName, tested on ios and android.
parent 858ca079
...@@ -184,7 +184,8 @@ var DeviceInfo = require('react-native-device-info'); ...@@ -184,7 +184,8 @@ var DeviceInfo = require('react-native-device-info');
| App Instance ID | `getInstanceID()` | | ANDROID ONLY - see https://developers.google.com/instance-id/ | | App Instance ID | `getInstanceID()` | | ANDROID ONLY - see https://developers.google.com/instance-id/ |
| App is running in emulator | `isEmulator()` | true | if app is running in emulator return true | | App is running in emulator | `isEmulator()` | true | if app is running in emulator return true |
| App is running on a tablet | `isTablet()` | true | if app is running on a tablet return true | | App is running on a tablet | `isTablet()` | true | if app is running on a tablet return true |
| PIN or fingerprint set | `isPinOrFingerprintSet()(callback)`| | Only supported in Android and iOS 9.0 and above | PIN or fingerprint set | `isPinOrFingerprintSet()(callback)`| | Only supported in Android and iOS 9.0 and above |
| App Name | `getApplicationName()` | 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:
......
...@@ -179,6 +179,7 @@ RCT_EXPORT_MODULE() ...@@ -179,6 +179,7 @@ RCT_EXPORT_MODULE()
@"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"],
......
...@@ -4,6 +4,7 @@ import android.app.KeyguardManager; ...@@ -4,6 +4,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.os.Build; import android.os.Build;
...@@ -85,15 +86,19 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -85,15 +86,19 @@ 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 info = packageManager.getPackageInfo(packageName, 0); PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
constants.put("appVersion", info.versionName); ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
constants.put("buildNumber", info.versionCode); constants.put("appVersion", packageInfo.versionName);
constants.put("buildNumber", packageInfo.versionCode);
constants.put("appName", packageManager.getApplicationLabel(applicationInfo).toString());
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -10,6 +10,7 @@ declare class DeviceInfo { ...@@ -10,6 +10,7 @@ declare class DeviceInfo {
public static getSystemName(): string; public static getSystemName(): string;
public static getSystemVersion(): string; public static getSystemVersion(): string;
public static getBundleId(): string; public static getBundleId(): string;
public static getApplicationName(): string;
public static getBuildNumber(): string; public static getBuildNumber(): string;
public static getVersion(): string; public static getVersion(): string;
public static getReadableVersion(): string; public static getReadableVersion(): string;
......
...@@ -32,6 +32,9 @@ module.exports = { ...@@ -32,6 +32,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;
}, },
......
...@@ -52,7 +52,8 @@ namespace RNDeviceInfo ...@@ -52,7 +52,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
{ {
...@@ -106,7 +107,8 @@ namespace RNDeviceInfo ...@@ -106,7 +107,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