Commit f22a65e3 authored by Igor Yegorov's avatar Igor Yegorov

Merge branch 'master' into typings

# Conflicts:
#	deviceinfo.d.ts
#	package.json
parents 2b3c8c11 5b869cdd
......@@ -159,43 +159,37 @@ See [CHANGELOG.md](https://github.com/rebeccahughes/react-native-device-info/blo
```js
var DeviceInfo = require('react-native-device-info');
// or import DeviceInfo from 'react-native-device-info';
```
console.log("Device Unique ID", DeviceInfo.getUniqueID()); // e.g. FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9
// * note this is IDFV on iOS so it will change if all apps from the current apps vendor have been previously uninstalled
console.log("Device Manufacturer", DeviceInfo.getManufacturer()); // e.g. Apple
console.log("Device Brand", DeviceInfo.getBrand()); // e.g. Apple / htc / Xiaomi
console.log("Device Model", DeviceInfo.getModel()); // e.g. iPhone 6
console.log("Device ID", DeviceInfo.getDeviceId()); // e.g. iPhone7,2 / or the board on Android e.g. goldfish
console.log("System Name", DeviceInfo.getSystemName()); // e.g. iPhone OS
console.log("System Version", DeviceInfo.getSystemVersion()); // e.g. 9.0
console.log("Bundle ID", DeviceInfo.getBundleId()); // e.g. com.learnium.mobile
console.log("Build Number", DeviceInfo.getBuildNumber()); // e.g. 89
console.log("App Version", DeviceInfo.getVersion()); // e.g. 1.1.0
console.log("App Version (Readable)", DeviceInfo.getReadableVersion()); // e.g. 1.1.0.89
console.log("Device Name", DeviceInfo.getDeviceName()); // e.g. Becca's iPhone 6
console.log("User Agent", DeviceInfo.getUserAgent()); // e.g. Dalvik/2.1.0 (Linux; U; Android 5.1; Google Nexus 4 - 5.1.0 - API 22 - 768x1280 Build/LMY47D)
console.log("Device Locale", DeviceInfo.getDeviceLocale()); // e.g en-US
console.log("Device Country", DeviceInfo.getDeviceCountry()); // e.g US
console.log("Timezone", DeviceInfo.getTimezone()); // e.g America/Mexico_City
console.log("App Instance ID", DeviceInfo.getInstanceID()); // ANDROID ONLY - see https://developers.google.com/instance-id/
console.log("App is running in emulator", DeviceInfo.isEmulator()); // if app is running in emulator return true
| 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 Manufacturer | `getManufacturer()` | Apple | |
| Device Brand | `getBrand()` | Apple / htc / Xiaomi | |
| Device Model | `getModel()` | iPhone 6 | |
| Device ID | `getDeviceId()` | iPhone7,2 | Or the board on Android e.g. goldfish |
| System Name | `getSystemName()` | iPhone OS | |
| System Version | `getSystemVersion()` | 9.0 | |
| Bundle ID | `getBundleId()` | com.learnium.mobile | |
| Build Number | `getBuildNumber()` | 89 | |
| App Version | `getVersion()` | 1.1.0 | |
| App Version (Readable) | `getReadableVersion()` | 1.1.0.89 | |
| Device Name | `getDeviceName()` | Becca's iPhone 6 | |
| User Agent | `getUserAgent()` | Dalvik/2.1.0 (Linux; U; Android 5.1; Google Nexus 4 - 5.1.0 - API 22 - 768x1280 Build/LMY47D) | |
| Device Locale | `getDeviceLocale()` | en-US | |
| Device Country | `getDeviceCountry()` | US | |
| Timezone | `getTimezone()` | America/Mexico_City | |
| 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
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 in your javascript:
console.log("App is running on a tablet", DeviceInfo.isTablet()); // if app is running on a tablet return true
```js
RNDeviceInfo.isPinOrFingerprintSet(isPinOrFingerprintSet => {
if (!isPinOrFingerprintSet) {
...
}
}
```
......@@ -219,6 +219,10 @@
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(BUILT_PRODUCTS_DIR)/usr/local/include",
"$(SRCROOT)/../../React/**",
"$(SRCROOT)/node_modules/react-native/React/**",
"$(SRCROOT)/../react-native/React/**",
"$(SRCROOT)/../../../node_modules/react-native/React/**"
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
OTHER_LDFLAGS = "-ObjC";
......@@ -233,6 +237,10 @@
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(BUILT_PRODUCTS_DIR)/usr/local/include",
"$(SRCROOT)/../../React/**",
"$(SRCROOT)/node_modules/react-native/React/**",
"$(SRCROOT)/../react-native/React/**",
"$(SRCROOT)/../../../node_modules/react-native/React/**"
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
OTHER_LDFLAGS = "-ObjC";
......
......@@ -9,7 +9,11 @@
#import <UIKit/UIKit.h>
#import <sys/utsname.h>
#import <React/RCTBridgeModule.h>
#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif
@interface RNDeviceInfo : NSObject <RCTBridgeModule>
......
......@@ -8,6 +8,7 @@
#import "RNDeviceInfo.h"
#import "DeviceUID.h"
#import <LocalAuthentication/LocalAuthentication.h>
@interface RNDeviceInfo()
......@@ -179,7 +180,7 @@ RCT_EXPORT_MODULE()
@"deviceCountry": self.deviceCountry ?: [NSNull null],
@"uniqueId": uniqueId,
@"bundleId": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"],
@"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"],
@"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ?: [NSNull null],
@"buildNumber": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"],
@"systemManufacturer": @"Apple",
@"userAgent": self.userAgent,
......@@ -189,4 +190,11 @@ RCT_EXPORT_MODULE()
};
}
RCT_EXPORT_METHOD(isPinOrFingerprintSet:(RCTResponseSenderBlock)callback)
{
LAContext *context = [[LAContext alloc] init];
BOOL isPinOrFingerprintSet = ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:nil]);
callback(@[[NSNumber numberWithBool:isPinOrFingerprintSet]]);
}
@end
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 16
......
package com.learnium.RNDeviceInfo;
import android.app.KeyguardManager;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
......@@ -11,6 +13,8 @@ import com.google.android.gms.iid.InstanceID;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;
import java.util.HashMap;
import java.util.Locale;
......@@ -69,6 +73,12 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
return layout == Configuration.SCREENLAYOUT_SIZE_LARGE || layout == Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
@ReactMethod
public void isPinOrFingerprintSet(Callback callback) {
KeyguardManager keyguardManager = (KeyguardManager) this.reactContext.getSystemService(Context.KEYGUARD_SERVICE); //api 16+
callback.invoke(keyguardManager.isKeyguardSecure());
}
@Override
public @Nullable Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<String, Object>();
......@@ -92,7 +102,9 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
try {
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
if(myDevice!=null){
deviceName = myDevice.getName();
}
} catch(Exception e) {
e.printStackTrace();
}
......
......@@ -21,6 +21,7 @@ declare class DeviceInfo {
public static getInstanceID(): string;
public static isEmulator(): boolean;
public static isTablet(): boolean;
public static isPinOrFingerprintSet(cb: (isSet: boolean) => void): void;
}
export default DeviceInfo;
......@@ -62,4 +62,7 @@ module.exports = {
isTablet: function() {
return RNDeviceInfo.isTablet;
},
isPinOrFingerprintSet: function () {
return RNDeviceInfo.isPinOrFingerprintSet;
},
};
{
"name": "react-native-device-info",
"version": "0.9.6",
"version": "0.10.2",
"description": "Get device information using react-native",
"main": "deviceinfo.js",
"types": "deviceinfo.d.ts",
"typings": "./deviceinfo.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/rebeccahughes/react-native-device-info"
......
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