Commit 71796205 authored by Gant Laborde's avatar Gant Laborde Committed by GitHub

Merge pull request #232 from firefueled/get-android-api-level

Add android-only getAPILevel method
parents 50357ab7 f7226362
...@@ -164,31 +164,32 @@ var DeviceInfo = require('react-native-device-info'); ...@@ -164,31 +164,32 @@ 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()` | 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()` | 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 Manufacturer | `getManufacturer()` | Apple | | | Device Manufacturer | `getManufacturer()` | Apple | |
| Device Brand | `getBrand()` | Apple / htc / Xiaomi | | | Device Brand | `getBrand()` | Apple / htc / Xiaomi | |
| Device Model | `getModel()` | iPhone 6 | | | Device Model | `getModel()` | iPhone 6 | |
| Device ID | `getDeviceId()` | iPhone7,2 | Or the board on Android e.g. goldfish | | Device ID | `getDeviceId()` | iPhone7,2 | Or the board on Android e.g. goldfish |
| System Name | `getSystemName()` | iPhone OS | | | System Name | `getSystemName()` | iPhone OS | |
| System Version | `getSystemVersion()` | 9.0 | | | System Version | `getSystemVersion()` | 9.0 | |
| Bundle ID | `getBundleId()` | com.learnium.mobile | | | API Level | `getAPILevel()` | 25 | ANDROID ONLY - see [API Levels](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)|
| Build Number | `getBuildNumber()` | 89 | | | Bundle ID | `getBundleId()` | com.learnium.mobile | |
| App Version | `getVersion()` | 1.1.0 | | | Build Number | `getBuildNumber()` | 89 | |
| App Version (Readable) | `getReadableVersion()` | 1.1.0.89 | | | App Version | `getVersion()` | 1.1.0 | |
| Device Name | `getDeviceName()` | Becca's iPhone 6 | | | App Version (Readable) | `getReadableVersion()` | 1.1.0.89 | |
| User Agent | `getUserAgent()` | Dalvik/2.1.0 (Linux; U; Android 5.1; Google Nexus 4 - 5.1.0 - API 22 - 768x1280 Build/LMY47D) | | | Device Name | `getDeviceName()` | Becca's iPhone 6 | |
| Device Locale | `getDeviceLocale()` | en-US | | | User Agent | `getUserAgent()` | Dalvik/2.1.0 (Linux; U; Android 5.1; Google Nexus 4 - 5.1.0 - API 22 - 768x1280 Build/LMY47D) | |
| Device Country | `getDeviceCountry()` | US | | | Device Locale | `getDeviceLocale()` | en-US | |
| Timezone | `getTimezone()` | America/Mexico_City | | | Device Country | `getDeviceCountry()` | US | |
| App Instance ID | `getInstanceID()` | | ANDROID ONLY - see https://developers.google.com/instance-id/ | | Timezone | `getTimezone()` | America/Mexico_City | |
| App is running in emulator | `isEmulator()` | true | if app is running in emulator return true | | App Instance ID | `getInstanceID()` | | ANDROID ONLY - see https://developers.google.com/instance-id/ |
| App is running on a tablet | `isTablet()` | true | if app is running on a tablet return true | | App is running in emulator | `isEmulator()` | true | if app is running in emulator return true |
| PIN or fingerprint set | `isPinOrFingerprintSet()(callback)`| | Only supported in Android and iOS 9.0 and above | App is running on a tablet | `isTablet()` | true | if app is running on a tablet return true |
| Phone Number | `getPhoneNumber()` | "2348675309" or "" or null | Only supported in Android | PIN or fingerprint set | `isPinOrFingerprintSet()(callback)`| | Only supported in Android and iOS 9.0 and above |
| First Install Time | `getFirstInstallTime()` | 1505607068808 | Only supported in Android | | Phone Number | `getPhoneNumber()` | "2348675309" or "" or null | Only supported in Android |
| Last Install Time | `getLastUpdateTime()` | 1505607068808 | Only supported in Android | | First Install Time | `getFirstInstallTime()` | 1505607068808 | Only supported in Android |
| Last Install Time | `getLastUpdateTime()` | 1505607068808 | Only supported in Android |
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:
......
...@@ -187,6 +187,7 @@ RCT_EXPORT_MODULE() ...@@ -187,6 +187,7 @@ RCT_EXPORT_MODULE()
return @{ return @{
@"systemName": currentDevice.systemName, @"systemName": currentDevice.systemName,
@"systemVersion": currentDevice.systemVersion, @"systemVersion": currentDevice.systemVersion,
@"apiLevel": @"not available",
@"model": self.deviceName, @"model": self.deviceName,
@"brand": @"Apple", @"brand": @"Apple",
@"deviceId": self.deviceId, @"deviceId": self.deviceId,
......
...@@ -121,6 +121,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -121,6 +121,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
constants.put("model", Build.MODEL); constants.put("model", Build.MODEL);
constants.put("brand", Build.BRAND); constants.put("brand", Build.BRAND);
constants.put("deviceId", Build.BOARD); constants.put("deviceId", Build.BOARD);
constants.put("apiLevel", Build.VERSION.SDK_INT);
constants.put("deviceLocale", this.getCurrentLanguage()); constants.put("deviceLocale", this.getCurrentLanguage());
constants.put("deviceCountry", this.getCurrentCountry()); constants.put("deviceCountry", this.getCurrentCountry());
constants.put("uniqueId", Secure.getString(this.reactContext.getContentResolver(), Secure.ANDROID_ID)); constants.put("uniqueId", Secure.getString(this.reactContext.getContentResolver(), Secure.ANDROID_ID));
......
...@@ -29,6 +29,9 @@ module.exports = { ...@@ -29,6 +29,9 @@ module.exports = {
getSystemVersion: function () { getSystemVersion: function () {
return RNDeviceInfo.systemVersion; return RNDeviceInfo.systemVersion;
}, },
getAPILevel: function () {
return RNDeviceInfo.apiLevel;
},
getBundleId: function() { getBundleId: function() {
return RNDeviceInfo.bundleId; return RNDeviceInfo.bundleId;
}, },
......
...@@ -99,6 +99,7 @@ namespace RNDeviceInfo ...@@ -99,6 +99,7 @@ namespace RNDeviceInfo
constants["deviceName"] = deviceName; constants["deviceName"] = deviceName;
constants["systemName"] = "Windows"; constants["systemName"] = "Windows";
constants["systemVersion"] = osVersion; constants["systemVersion"] = osVersion;
constants["apiLevel"] = "not available";
constants["model"] = model; constants["model"] = model;
constants["brand"] = model; constants["brand"] = model;
constants["deviceId"] = hardwareVersion; constants["deviceId"] = hardwareVersion;
......
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