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 ...@@ -159,43 +159,37 @@ See [CHANGELOG.md](https://github.com/rebeccahughes/react-native-device-info/blo
```js ```js
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';
```
console.log("Device Unique ID", DeviceInfo.getUniqueID()); // e.g. FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9 | Name | Method | Return | Notes |
// * note 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. |
console.log("Device Manufacturer", DeviceInfo.getManufacturer()); // e.g. Apple | Device Manufacturer | `getManufacturer()` | Apple | |
| Device Brand | `getBrand()` | Apple / htc / Xiaomi | |
console.log("Device Brand", DeviceInfo.getBrand()); // e.g. Apple / htc / Xiaomi | Device Model | `getModel()` | iPhone 6 | |
| Device ID | `getDeviceId()` | iPhone7,2 | Or the board on Android e.g. goldfish |
console.log("Device Model", DeviceInfo.getModel()); // e.g. iPhone 6 | System Name | `getSystemName()` | iPhone OS | |
| System Version | `getSystemVersion()` | 9.0 | |
console.log("Device ID", DeviceInfo.getDeviceId()); // e.g. iPhone7,2 / or the board on Android e.g. goldfish | Bundle ID | `getBundleId()` | com.learnium.mobile | |
| Build Number | `getBuildNumber()` | 89 | |
console.log("System Name", DeviceInfo.getSystemName()); // e.g. iPhone OS | App Version | `getVersion()` | 1.1.0 | |
| App Version (Readable) | `getReadableVersion()` | 1.1.0.89 | |
console.log("System Version", DeviceInfo.getSystemVersion()); // e.g. 9.0 | 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) | |
console.log("Bundle ID", DeviceInfo.getBundleId()); // e.g. com.learnium.mobile | Device Locale | `getDeviceLocale()` | en-US | |
| Device Country | `getDeviceCountry()` | US | |
console.log("Build Number", DeviceInfo.getBuildNumber()); // e.g. 89 | Timezone | `getTimezone()` | America/Mexico_City | |
| App Instance ID | `getInstanceID()` | | ANDROID ONLY - see https://developers.google.com/instance-id/ |
console.log("App Version", DeviceInfo.getVersion()); // e.g. 1.1.0 | 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 |
console.log("App Version (Readable)", DeviceInfo.getReadableVersion()); // e.g. 1.1.0.89 | PIN or fingerprint set | `isPinOrFingerprintSet(callback)`| | Only supported in Android and iOS 9.0 and above
console.log("Device Name", DeviceInfo.getDeviceName()); // e.g. Becca's iPhone 6 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("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
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 @@ ...@@ -219,6 +219,10 @@
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(BUILT_PRODUCTS_DIR)/usr/local/include", "$(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; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
OTHER_LDFLAGS = "-ObjC"; OTHER_LDFLAGS = "-ObjC";
...@@ -233,6 +237,10 @@ ...@@ -233,6 +237,10 @@
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(BUILT_PRODUCTS_DIR)/usr/local/include", "$(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; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
OTHER_LDFLAGS = "-ObjC"; OTHER_LDFLAGS = "-ObjC";
......
...@@ -9,7 +9,11 @@ ...@@ -9,7 +9,11 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <sys/utsname.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> @interface RNDeviceInfo : NSObject <RCTBridgeModule>
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import "RNDeviceInfo.h" #import "RNDeviceInfo.h"
#import "DeviceUID.h" #import "DeviceUID.h"
#import <LocalAuthentication/LocalAuthentication.h>
@interface RNDeviceInfo() @interface RNDeviceInfo()
...@@ -179,7 +180,7 @@ RCT_EXPORT_MODULE() ...@@ -179,7 +180,7 @@ RCT_EXPORT_MODULE()
@"deviceCountry": self.deviceCountry ?: [NSNull null], @"deviceCountry": self.deviceCountry ?: [NSNull null],
@"uniqueId": uniqueId, @"uniqueId": uniqueId,
@"bundleId": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"], @"bundleId": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"],
@"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], @"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ?: [NSNull null],
@"buildNumber": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"], @"buildNumber": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"],
@"systemManufacturer": @"Apple", @"systemManufacturer": @"Apple",
@"userAgent": self.userAgent, @"userAgent": self.userAgent,
...@@ -189,4 +190,11 @@ RCT_EXPORT_MODULE() ...@@ -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 @end
...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
android { android {
compileSdkVersion 23 compileSdkVersion 23
buildToolsVersion "23.0.1" buildToolsVersion "25.0.2"
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
......
package com.learnium.RNDeviceInfo; package com.learnium.RNDeviceInfo;
import android.app.KeyguardManager;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
...@@ -11,6 +13,8 @@ import com.google.android.gms.iid.InstanceID; ...@@ -11,6 +13,8 @@ import com.google.android.gms.iid.InstanceID;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; 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.HashMap;
import java.util.Locale; import java.util.Locale;
...@@ -69,6 +73,12 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -69,6 +73,12 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
return layout == Configuration.SCREENLAYOUT_SIZE_LARGE || layout == Configuration.SCREENLAYOUT_SIZE_XLARGE; 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 @Override
public @Nullable Map<String, Object> getConstants() { public @Nullable Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<String, Object>(); HashMap<String, Object> constants = new HashMap<String, Object>();
...@@ -92,7 +102,9 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -92,7 +102,9 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
try { try {
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter(); BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
deviceName = myDevice.getName(); if(myDevice!=null){
deviceName = myDevice.getName();
}
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -21,6 +21,7 @@ declare class DeviceInfo { ...@@ -21,6 +21,7 @@ declare class DeviceInfo {
public static getInstanceID(): string; public static getInstanceID(): string;
public static isEmulator(): boolean; public static isEmulator(): boolean;
public static isTablet(): boolean; public static isTablet(): boolean;
public static isPinOrFingerprintSet(cb: (isSet: boolean) => void): void;
} }
export default DeviceInfo; export default DeviceInfo;
...@@ -62,4 +62,7 @@ module.exports = { ...@@ -62,4 +62,7 @@ module.exports = {
isTablet: function() { isTablet: function() {
return RNDeviceInfo.isTablet; return RNDeviceInfo.isTablet;
}, },
isPinOrFingerprintSet: function () {
return RNDeviceInfo.isPinOrFingerprintSet;
},
}; };
{ {
"name": "react-native-device-info", "name": "react-native-device-info",
"version": "0.9.6", "version": "0.10.2",
"description": "Get device information using react-native", "description": "Get device information using react-native",
"main": "deviceinfo.js", "main": "deviceinfo.js",
"types": "deviceinfo.d.ts", "typings": "./deviceinfo.d.ts",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/rebeccahughes/react-native-device-info" "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