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');
| 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 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:
......
......@@ -179,6 +179,7 @@ RCT_EXPORT_MODULE()
@"deviceLocale": self.deviceLocale,
@"deviceCountry": self.deviceCountry ?: [NSNull null],
@"uniqueId": uniqueId,
@"appName": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"],
@"bundleId": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"],
@"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ?: [NSNull null],
@"buildNumber": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"],
......
......@@ -4,6 +4,7 @@ import android.app.KeyguardManager;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Build;
......@@ -85,15 +86,19 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
PackageManager packageManager = this.reactContext.getPackageManager();
String packageName = this.reactContext.getPackageName();
String applicationName = this.reactContext.getApplicationInfo().loadLabel(this.reactContext.getPackageManager()).toString();
constants.put("appVersion", "not available");
constants.put("appName", "not available");
constants.put("buildVersion", "not available");
constants.put("buildNumber", 0);
try {
PackageInfo info = packageManager.getPackageInfo(packageName, 0);
constants.put("appVersion", info.versionName);
constants.put("buildNumber", info.versionCode);
PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
constants.put("appVersion", packageInfo.versionName);
constants.put("buildNumber", packageInfo.versionCode);
constants.put("appName", packageManager.getApplicationLabel(applicationInfo).toString());
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
......
......@@ -10,6 +10,7 @@ declare class DeviceInfo {
public static getSystemName(): string;
public static getSystemVersion(): string;
public static getBundleId(): string;
public static getApplicationName(): string;
public static getBuildNumber(): string;
public static getVersion(): string;
public static getReadableVersion(): string;
......
......@@ -32,6 +32,9 @@ module.exports = {
getBundleId: function() {
return RNDeviceInfo.bundleId;
},
getApplicationName: function() {
return RNDeviceInfo.appName;
},
getBuildNumber: function() {
return RNDeviceInfo.buildNumber;
},
......
......@@ -52,7 +52,8 @@ namespace RNDeviceInfo
Package package = Package.Current;
PackageId packageId = package.Id;
PackageVersion version = packageId.Version;
String packageName = package.DisplayName;
String bundleId = packageId.Name;
String appName = package.DisplayName;
try
{
......@@ -94,7 +95,7 @@ namespace RNDeviceInfo
catch
{
}
constants["instanceId"] = "not available";
constants["deviceName"] = deviceName;
constants["systemName"] = "Windows";
......@@ -106,7 +107,8 @@ namespace RNDeviceInfo
constants["deviceCountry"] = culture.EnglishName;
constants["uniqueId"] = device_id;
constants["systemManufacturer"] = manufacturer;
constants["bundleId"] = packageName;
constants["bundleId"] = bundleId;
constants["appName"] = appName;
constants["userAgent"] = "not available";
constants["timezone"] = TimeZoneInfo.Local.Id;
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