Commit 27c4b076 authored by Gant Laborde's avatar Gant Laborde
Browse files

merge

parents 35501dcf 53d75f1e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
## Release Notes

### 0.9.7

Several bugfixes and detecting if device is a tablet

### 0.9.3 

adds support for Brand information e.g. apple, htc, etc
+54 −37
Original line number Diff line number Diff line
@@ -118,6 +118,29 @@ include ':app'

(Thanks to @chirag04 for writing the instructions)

### Windows
- Open the solution in Visual Studio for your Windows apps
- right click your in the Explorer and click Add > Existing Project...
- Navigate to `./<app-name>/node_modules/react-native-device-info/windows/RNDeviceInfo` and add `RNDeviceInfo.csproj`
- this time right click on your React Native Windows app under your solutions directory and click Add > Reference...
- check the `RNDeviceInfo` you just added and press ok
- open up `MainPage.cs` for your app and edit the file like so:

```diff
+ using RNDeviceInfo;
......
            get
            {
                return new List<IReactPackage>
                {
                    new MainReactPackage(),
+                   new RNDeviceInfoPackage(),
                };
            }
```

(Thanks to @josephan for writing the instructions)

## Device Name

If you want to get the device name in Android add this to your `AndroidManifest.xml` (optional):
@@ -136,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) {
    ...
  }
}
```
+6 −4
Original line number Diff line number Diff line
@@ -217,11 +217,12 @@
			isa = XCBuildConfiguration;
			buildSettings = {
				HEADER_SEARCH_PATHS = (
					"$(SRCROOT)/../../React/**",
					"$(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/**",
					"$(SRCROOT)/../../../node_modules/react-native/React/**"
				);
				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
				OTHER_LDFLAGS = "-ObjC";
@@ -234,11 +235,12 @@
			isa = XCBuildConfiguration;
			buildSettings = {
				HEADER_SEARCH_PATHS = (
					"$(SRCROOT)/../../React/**",
					"$(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/**",
					"$(SRCROOT)/../../../node_modules/react-native/React/**"
				);
				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
				OTHER_LDFLAGS = "-ObjC";
+5 −1
Original line number Diff line number Diff line
@@ -9,7 +9,11 @@
#import <UIKit/UIKit.h>
#import <sys/utsname.h>

#if __has_include("RCTBridgeModule.h")
    #import "RCTBridgeModule.h"
#else
    #import <React/RCTBridgeModule.h>
#endif

@interface RNDeviceInfo : NSObject <RCTBridgeModule>

+9 −1
Original line number Diff line number Diff line
@@ -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
Loading