react-native-device-info
Advanced tools
Comparing version 0.14.0 to 0.15.0
## Release Notes | ||
### Next | ||
### 0.15.0 | ||
* Add `getFontScale` (https://github.com/rebeccahughes/react-native-device-info/pull/278) | ||
* Add `getFreeDiskStorage` and `getTotalDiskCapacity` (https://github.com/rebeccahughes/react-native-device-info/pull/302) | ||
* Fix missing flow definition for `getApplicationName` | ||
### 0.14.0 | ||
@@ -32,3 +40,3 @@ | ||
* Fix typescript definitions (https://github.com/rebeccahughes/react-native-device-info/pull/221) | ||
* Add `getFirstInstallTime` and `getLastInstallTime` (https://github.com/rebeccahughes/react-native-device-info/pull/222) | ||
* Add `getFirstInstallTime` and `getLastUpdateTime` (https://github.com/rebeccahughes/react-native-device-info/pull/222) | ||
* Added version check and permission to work with Android API >= 16 (https://github.com/rebeccahughes/react-native-device-info/pull/225) | ||
@@ -35,0 +43,0 @@ * Added device detection even when in an iOS emulator (https://github.com/rebeccahughes/react-native-device-info/pull/224) |
@@ -1,2 +0,2 @@ | ||
// should be imported this way: | ||
// should be imported this way: | ||
// import * as DeviceInfo from 'react-native-device-info'; | ||
@@ -24,4 +24,7 @@ | ||
export function isTablet(): boolean; | ||
export function getFontScale(): number; | ||
export function is24Hour(): boolean; | ||
export function isPinOrFingerprintSet(): (cb: (isPinOrFingerprintSet: boolean) => void) => void; | ||
export function isPinOrFingerprintSet(): ( | ||
cb: (isPinOrFingerprintSet: boolean) => void | ||
) => void; | ||
export function getFirstInstallTime(): number; | ||
@@ -37,1 +40,3 @@ export function getLastUpdateTime(): number; | ||
export function getMaxMemory(): number; | ||
export function getTotalDiskCapacity(): number; | ||
export function getFreeDiskStorage(): number; |
@@ -74,2 +74,5 @@ /** | ||
}, | ||
getFontScale: function() { | ||
return RNDeviceInfo.fontScale; | ||
}, | ||
isEmulator: function() { | ||
@@ -84,3 +87,3 @@ return RNDeviceInfo.isEmulator; | ||
}, | ||
isPinOrFingerprintSet: function () { | ||
isPinOrFingerprintSet: function() { | ||
return RNDeviceInfo.isPinOrFingerprintSet; | ||
@@ -106,2 +109,8 @@ }, | ||
}, | ||
getTotalDiskCapacity: function () { | ||
return RNDeviceInfo.totalDiskCapacity; | ||
}, | ||
getFreeDiskStorage: function () { | ||
return RNDeviceInfo.freeDiskStorage; | ||
} | ||
}; |
{ | ||
"name": "react-native-device-info", | ||
"version": "0.14.0", | ||
"version": "0.15.0", | ||
"description": "Get device information using react-native", | ||
@@ -34,4 +34,5 @@ "main": "deviceinfo.js", | ||
"devDependencies": { | ||
"np": "^2.16.0" | ||
"np": "^2.16.0", | ||
"prettier": "^1.10.2" | ||
} | ||
} |
725
README.md
@@ -5,6 +5,16 @@ # react-native-device-info | ||
Device Information for [React Native](https://github.com/facebook/react-native) | ||
Device Information for [React Native](https://github.com/facebook/react-native). | ||
## Install | ||
## TOC | ||
* [Installation](#installation) | ||
* [Linking](#linking) | ||
* [Usage](#usage) | ||
* [API](#api) | ||
* [Release Notes](#release-notes) | ||
## Installation | ||
Using npm: | ||
```shell | ||
@@ -14,8 +24,14 @@ npm install --save react-native-device-info | ||
#### RN > 0.47 use 0.11 or higher | ||
or using yarn: | ||
## Automatically link | ||
```shell | ||
yarn add react-native-device-info | ||
``` | ||
#### With React Native 0.27+ | ||
> ⚠️ If you are on React Native > 0.47, you must use version 0.11.0 of this library or higher | ||
## Linking | ||
### Automatic | ||
```shell | ||
@@ -25,6 +41,4 @@ react-native link react-native-device-info | ||
#### With older versions of React Native | ||
(or using [`rnpm`](https://github.com/rnpm/rnpm) for versions of React Native < 0.27) | ||
You need [`rnpm`](https://github.com/rnpm/rnpm) (`npm install -g rnpm`) | ||
```shell | ||
@@ -34,5 +48,7 @@ rnpm link react-native-device-info | ||
## Manually link | ||
### Manual | ||
### iOS (via Cocoa Pods) | ||
<details> | ||
<summary>iOS (via Cocoa Pods)</summary> | ||
Add the following line to your build targets in your `Podfile` | ||
@@ -44,16 +60,21 @@ | ||
### iOS (without Cocoa Pods) | ||
</details> | ||
<details> | ||
<summary>iOS (without Cocoa Pods)</summary> | ||
In XCode, in the project navigator: | ||
- Right click _Libraries_ | ||
- Add Files to _[your project's name]_ | ||
- Go to `node_modules/react-native-device-info` | ||
- Add the `.xcodeproj` file | ||
* Right click _Libraries_ | ||
* Add Files to _[your project's name]_ | ||
* Go to `node_modules/react-native-device-info` | ||
* Add the `.xcodeproj` file | ||
In XCode, in the project navigator, select your project. | ||
- Add the `libRNDeviceInfo.a` from the _deviceinfo_ project to your project's _Build Phases ➜ Link Binary With Libraries_ | ||
- Click `.xcodeproj` file you added before in the project navigator and go the _Build Settings_ tab. Make sure _All_ is toggled on (instead of _Basic_). | ||
- Look for _Header Search Paths_ and make sure it contains both `$(SRCROOT)/../react-native/React` and `$(SRCROOT)/../../React` | ||
- Mark both as recursive (should be OK by default). | ||
* Add the `libRNDeviceInfo.a` from the _deviceinfo_ project to your project's _Build Phases ➜ Link Binary With Libraries_ | ||
* Click `.xcodeproj` file you added before in the project navigator and go the _Build Settings_ tab. Make sure _All_ is toggled on (instead of _Basic_). | ||
* Look for _Header Search Paths_ and make sure it contains both `$(SRCROOT)/../react-native/React` and `$(SRCROOT)/../../React` | ||
* Mark both as recursive (should be OK by default). | ||
Run your project (Cmd+R) | ||
@@ -63,6 +84,9 @@ | ||
### Android | ||
</details> | ||
- in `android/app/build.gradle`: | ||
<details> | ||
<summary>Android</summary> | ||
* in `android/app/build.gradle`: | ||
```diff | ||
@@ -76,3 +100,3 @@ dependencies { | ||
- in `android/settings.gradle`: | ||
* in `android/settings.gradle`: | ||
@@ -88,3 +112,3 @@ ```diff | ||
- in `MainApplication.java`: | ||
* in `MainApplication.java`: | ||
@@ -111,3 +135,3 @@ ```diff | ||
- in `MainActivity.java`: | ||
* in `MainActivity.java`: | ||
@@ -132,10 +156,14 @@ ```diff | ||
### 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: | ||
</details> | ||
<details> | ||
<summary>Windows</summary> | ||
* 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 | ||
@@ -156,61 +184,581 @@ + using RNDeviceInfo; | ||
## Permissions | ||
</details> | ||
Add the appropriate, optional permissions to your `AndroidManifest.xml`: | ||
## Usage | ||
```xml | ||
... | ||
<uses-permission android:name="android.permission.BLUETOOTH"/> <!-- for Device Name --> | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/> <!-- for Phone Number --> | ||
```js | ||
var DeviceInfo = require('react-native-device-info'); | ||
// or import DeviceInfo from 'react-native-device-info'; | ||
``` | ||
## Release Notes | ||
## API | ||
See [CHANGELOG.md](https://github.com/rebeccahughes/react-native-device-info/blob/master/CHANGELOG.md) | ||
| Method | Return Type | iOS | Android | Windows | Since | | ||
| ------------------------------------------------- | ------------------- | :--: | :-----: | :-----: | ------ | | ||
| [getAPILevel()](#getapilevel) | `number` | ❌ | ✅ | ❌ | 0.12.0 | | ||
| [getApplicationName()](#getapplicationname) | `string` | ✅ | ✅ | ✅ | 0.14.0 | | ||
| [getBrand()](#getbrand) | `string` | ✅ | ✅ | ✅ | 0.9.3 | | ||
| [getBuildNumber()](#getbuildnumber) | `string` | ✅ | ✅ | ✅ | ? | | ||
| [getBundleId()](#getbundleid) | `string` | ✅ | ✅ | ✅ | ? | | ||
| [getCarrier()](#getcarrier) | `string` | ✅ | ✅ | ❌ | 0.13.0 | | ||
| [getDeviceCountry()](#getdevicecountry) | `string` | ✅ | ✅ | ✅ | 0.9.0 | | ||
| [getDeviceId()](#getdeviceid) | `string` | ✅ | ✅ | ✅ | 0.5.0 | | ||
| [getDeviceLocale()](#getdevicelocale) | `string` | ✅ | ✅ | ✅ | 0.7.0 | | ||
| [getDeviceName()](#getdevicename) | `string` | ✅ | ✅ | ✅ | ? | | ||
| [getFirstInstallTime()](#getfirstinstalltime) | `number` | ❌ | ✅ | ❌ | 0.12.0 | | ||
| [getFontScale()](#getfontscale) | `number` | ✅ | ✅ | ❌ | 0.15.0 | | ||
| [getFreeDiskStorage()](#getfreediskstorage) | `number` | ✅ | ✅ | ❌ | 0.15.0 | | ||
| [getIPAddress()](#getipaddress) | `Promise<string>` | ❌ | ✅ | ❌ | 0.12.0 | | ||
| [getInstanceID()](#getinstanceid) | `string` | ❌ | ✅ | ❌ | ? | | ||
| [getLastUpdateTime()](#getlastupdatetime) | `number` | ❌ | ✅ | ❌ | 0.12.0 | | ||
| [getMACAddress()](#getmacaddress) | `Promise<string>` | ❌ | ✅ | ❌ | 0.12.0 | | ||
| [getManufacturer()](#getmanufacturer) | `string` | ✅ | ✅ | ✅ | ? | | ||
| [getMaxMemory()](#getmaxmemory) | `number` | ❌ | ✅ | ❌ | 0.14.0 | | ||
| [getModel()](#getmodel) | `string` | ✅ | ✅ | ✅ | ? | | ||
| [getPhoneNumber()](#getphonenumber) | `string` | ❌ | ✅ | ❌ | 0.12.0 | | ||
| [getReadableVersion()](#getreadableversion) | `string` | ✅ | ✅ | ✅ | ? | | ||
| [getSerialNumber()](#getserialnumber) | `string` | ❌ | ✅ | ❌ | 0.12.0 | | ||
| [getSystemName()](#getsystemname) | `string` | ✅ | ✅ | ✅ | ? | | ||
| [getSystemVersion()](#getsystemversion) | `string` | ✅ | ✅ | ✅ | ? | | ||
| [getTimezone()](#gettimezone) | `string` | ✅ | ✅ | ✅ | ? | | ||
| [getTotalDiskCapacity()](#gettotaldiskcapacity) | `number` | ✅ | ✅ | ❌ | 0.15.0 | | ||
| [getTotalMemory()](#gettotalmemory) | `number` | ✅ | ✅ | ❌ | 0.14.0 | | ||
| [getUniqueID()](#getuniqueid) | `string` | ✅ | ✅ | ✅ | ? | | ||
| [getUserAgent()](#getuseragent) | `string` | ✅ | ✅ | ❌ | 0.7.0 | | ||
| [getVersion()](#getversion) | `string` | ✅ | ✅ | ✅ | ? | | ||
| [is24Hour()](#is24hour) | `boolean` | ✅ | ✅ | ✅ | 0.13.0 | | ||
| [isEmulator()](#isemulator) | `boolean` | ✅ | ✅ | ✅ | ? | | ||
| [isPinOrFingerprintSet()](#ispinorfingerprintset) | (callback)`boolean` | ✅ | ✅ | ❌ | 0.10.1 | | ||
| [isTablet()](#istablet) | `boolean` | ✅ | ✅ | ✅ | ? | | ||
## Example | ||
--- | ||
### getAPILevel() | ||
Gets the API level. | ||
**Examples** | ||
```js | ||
var DeviceInfo = require('react-native-device-info'); | ||
// or import DeviceInfo from 'react-native-device-info'; | ||
const apiLevel = DeviceInfo.getAPILevel(); | ||
// iOS: ? | ||
// Android: 25 | ||
// Windows: ? | ||
``` | ||
| Name | Method | Return | Notes | | ||
| :------------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- | | ||
| Device Unique ID | `getUniqueID()` | `string` e.g. "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()` | `string` e.g. "Apple" | | | ||
| Device Brand | `getBrand()` | `string` e.g. "Apple / htc / Xiaomi" | | | ||
| Device Model | `getModel()` | `string` e.g. "iPhone 6" | | | ||
| Device ID | `getDeviceId()` | `string` e.g. "iPhone7,2" | Or the board on Android e.g. goldfish | | ||
| Device is set to 24 hour time format | `is24Hour()` | `boolean` e.g. true | | | ||
| System Name | `getSystemName()` | `string` e.g. "iPhone OS" | | | ||
| System Version | `getSystemVersion()` | `string` e.g. "9.0" | | | ||
| Bundle ID | `getBundleId()` | `string` e.g. "com.learnium.mobile" | | | ||
| Build Number | `getBuildNumber()` | `string` e.g. "89" | | | ||
| App Version | `getVersion()` | `string` e.g. "1.1.0" | | | ||
| App Version (Readable) | `getReadableVersion()` | `string` e.g. "1.1.0.89" | | | ||
| Device Name | `getDeviceName()` | `string` e.g. "Becca's iPhone 6" | | | ||
| User Agent | `getUserAgent()` | `string` e.g. "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.009; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.98 Mobile Safari/537.36" | | | ||
| Device Locale | `getDeviceLocale()` | `string` e.g. "en-US" | | | ||
| Device Country | `getDeviceCountry()` | `string` e.g. "US" | | | ||
| Timezone | `getTimezone()` | `string` e.g. "America/Mexico_City" | | | ||
| App is running in emulator | `isEmulator()` | `boolean` e.g. true | if app is running in emulator return true | | ||
| App is running on a tablet | `isTablet()` | `boolean` e.g. true | if app is running on a tablet return true | | ||
| PIN or fingerprint set | `isPinOrFingerprintSet()` | `(callback: (isPinOrFingerprintSet: boolean) => void) => void` | Only supported in Android and iOS 9.0 and above | | ||
| API Level | `getAPILevel()` | `number` e.g. 25 | ANDROID ONLY - see [API Levels](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)| | ||
| App Instance ID | `getInstanceID()` | `string` | ANDROID ONLY - see https://developers.google.com/instance-id/ | | ||
| Phone Number | `getPhoneNumber()` | `?string` e.g. "2348675309" or "" | Only supported in Android | | ||
| First Install Time | `getFirstInstallTime()` | `number` e.g. 1505607068808 | Only supported in Android | | ||
| Last Install Time | `getLastUpdateTime()` | `number` e.g. 1505607068808 | Only supported in Android | | ||
| Serial Number | `getSerialNumber()` | `string` | Only supported in Android | | ||
| IP Address | `getIPAddress()` | `Promise<string>` | Only supported in Android | | ||
| MAC Address | `getMACAddress()` | `Promise<string>` | Only supported in Android | | ||
| Carrier | `getCarrier()` | `string` e.g. "SOFTBANK" | | | ||
| Total Memory | `getTotalMemory()` | `number` e.g. 1995018240 | Total amount of memory on the device | | ||
| Max Memory | `getMaxMemory()` | `number` e.g. 268435456 | ANDROID ONLY - see https://developer.android.com/reference/java/lang/Runtime.html#maxMemory() | | ||
| App Name | `getApplicationName()` | `string` e.g.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: | ||
**Notes** | ||
> See [API Levels](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) | ||
--- | ||
### getApplicationName() | ||
Gets the application name. | ||
**Examples** | ||
```js | ||
RNDeviceInfo.isPinOrFingerprintSet()(isPinOrFingerprintSet => { | ||
const appName = DeviceInfo.getApplicationName(); // "Learnium Mobile" | ||
``` | ||
--- | ||
### getBrand() | ||
Gets the device brand. | ||
**Examples** | ||
```js | ||
const brand = DeviceInfo.getBrand(); | ||
// iOS: "Apple" | ||
// Android: "Xiaomi" | ||
// Windows: ? | ||
``` | ||
--- | ||
### getBuildNumber() | ||
Gets the application build number. | ||
**Examples** | ||
```js | ||
const buildNumber = DeviceInfo.getBuildNumber(); | ||
// iOS: "89" | ||
// Android: 4 | ||
// Windows: ? | ||
``` | ||
**Notes** | ||
> There is a type inconsistency: Android return an integer instead of the documented string. | ||
--- | ||
### getBundleId() | ||
Gets the application bundle identifier. | ||
**Examples** | ||
```js | ||
const bundleId = DeviceInfo.getBundleId(); // "com.learnium.mobile" | ||
``` | ||
--- | ||
### getCarrier() | ||
Gets the carrier name (network operator). | ||
**Examples** | ||
```js | ||
const carrier = DeviceInfo.getCarrier(); // "SOFTBANK" | ||
``` | ||
--- | ||
### getDeviceCountry() | ||
Gets the device country based on the locale information. | ||
**Examples** | ||
```js | ||
const deviceCountry = DeviceInfo.getDeviceCountry(); // "US" | ||
``` | ||
--- | ||
### getDeviceId() | ||
Gets the device ID. | ||
**Examples** | ||
```js | ||
const deviceId = DeviceInfo.getDeviceId(); | ||
// iOS: "iPhone7,2" | ||
// Android: "goldfish" | ||
// Windows: ? | ||
``` | ||
--- | ||
### getDeviceLocale() | ||
Gets the device locale. | ||
**Examples** | ||
```js | ||
const deviceLocale = DeviceInfo.getDeviceLocale(); | ||
// iOS: "en" | ||
// Android: "en-US" | ||
// Windows: ? | ||
``` | ||
--- | ||
### getDeviceName() | ||
Gets the device name. | ||
**Examples** | ||
```js | ||
const deviceName = DeviceInfo.getDeviceName(); | ||
// iOS: "Becca's iPhone 6" | ||
// Android: ? | ||
// Windows: ? | ||
``` | ||
**Android Permissions** | ||
* [android.permission.BLUETOOTH](https://developer.android.com/reference/android/Manifest.permission.html#BLUETOOTH) | ||
--- | ||
### getFirstInstallTime() | ||
Gets the time at which the app was first installed, in milliseconds. | ||
**Examples** | ||
```js | ||
const firstInstallTime = DeviceInfo.getFirstInstallTime(); | ||
// Android: 1517681764528 | ||
``` | ||
--- | ||
### getFontScale() | ||
Gets the device font scale. | ||
The font scale is the ratio of the current system font to the "normal" font size, so if normal text is 10pt and the system font is currently 15pt, the font scale would be 1.5 | ||
This can be used to determine if accessability settings has been changed for the device; you may want to re-layout certain views if the font scale is significantly larger ( > 2.0 ) | ||
**Examples** | ||
```js | ||
const fontScale = DeviceInfo.getFontScale(); // 1.2 | ||
``` | ||
--- | ||
### getFreeDiskStorage() | ||
Gets available storage size, in bytes. | ||
**Examples** | ||
```js | ||
const freeDiskStorage = DeviceInfo.getFreeDiskStorage(); | ||
// Android: 17179869184 | ||
// iOS: 17179869184 | ||
``` | ||
**Notes** | ||
> Android: Returns only available external storage size, not including internal. | ||
--- | ||
### getIPAddress() | ||
Gets the device current IP address. | ||
**Examples** | ||
```js | ||
DeviceInfo.getIPAddress().then(ip => { | ||
// "92.168.32.44" | ||
}); | ||
``` | ||
**Android Permissions** | ||
* [android.permission.ACCESS_WIFI_STATE](https://developer.android.com/reference/android/Manifest.permission.html#ACCESS_WIFI_STATE) | ||
--- | ||
### getInstanceID() | ||
Gets the application instance ID. | ||
**Examples** | ||
```js | ||
const instanceId = DeviceInfo.getInstanceID(); | ||
// Android: ? | ||
``` | ||
**Notes** | ||
> See https://developers.google.com/instance-id/ | ||
--- | ||
### getLastUpdateTime() | ||
Gets the time at which the app was last updated, in milliseconds. | ||
**Examples** | ||
```js | ||
const lastUpdateTime = DeviceInfo.getLastUpdateTime(); | ||
// Android: 1517681764992 | ||
``` | ||
--- | ||
### getMACAddress() | ||
Gets the network adapter MAC address. | ||
**Examples** | ||
```js | ||
DeviceInfo.getMACAddress().then(mac => { | ||
// "E5:12:D8:E5:69:97" | ||
}); | ||
``` | ||
**Android Permissions** | ||
* [android.permission.ACCESS_WIFI_STATE](https://developer.android.com/reference/android/Manifest.permission.html#ACCESS_WIFI_STATE) | ||
--- | ||
### getManufacturer() | ||
Gets the device manufacturer. | ||
**Examples** | ||
```js | ||
const manufacturer = DeviceInfo.getManufacturer(); | ||
// iOS: "Apple" | ||
// Android: "Google" | ||
// Windows: ? | ||
``` | ||
--- | ||
### getMaxMemory() | ||
Returns the maximum amount of memory that the JVM will attempt to use, in bytes. | ||
**Examples** | ||
```js | ||
const maxMemory = DeviceInfo.getMaxMemory(); | ||
// iOS: undefined | ||
// Android: 402653184 | ||
// Windows: ? | ||
``` | ||
--- | ||
### getModel() | ||
Gets the device model. | ||
**Examples** | ||
```js | ||
const model = DeviceInfo.getModel(); | ||
// iOS: ? | ||
// Android: ? | ||
// Windows: ? | ||
``` | ||
--- | ||
### getPhoneNumber() | ||
Gets the device phone number. | ||
**Examples** | ||
```js | ||
const phoneNumber = DeviceInfo.getPhoneNumber(); | ||
// Android: ? | ||
``` | ||
**Android Permissions** | ||
* [android.permission.READ_PHONE_STATE](https://developer.android.com/reference/android/Manifest.permission.html#READ_PHONE_STATE) | ||
--- | ||
### getReadableVersion() | ||
Gets the application human readable version. | ||
**Examples** | ||
```js | ||
const readableVersion = DeviceInfo.getReadableVersion(); | ||
// iOS: 1.0.1 | ||
// Android: 1.0.1 | ||
// Windows: ? | ||
``` | ||
--- | ||
### getSerialNumber() | ||
Gets the device serial number. | ||
**Examples** | ||
```js | ||
const serialNumber = DeviceInfo.getSerialNumber(); | ||
// iOS: undefined | ||
// Android: ? | ||
// Windows: ? | ||
``` | ||
--- | ||
### getSystemName() | ||
Gets the device OS name. | ||
**Examples** | ||
```js | ||
const systemName = DeviceInfo.getSystemName(); | ||
// iOS: "iOS" | ||
// Android: "Android" | ||
// Windows: ? | ||
``` | ||
--- | ||
### getSystemVersion() | ||
Gets the device OS version. | ||
**Examples** | ||
```js | ||
const systemVersion = DeviceInfo.getSystemVersion(); | ||
// iOS: "11.0" | ||
// Android: "7.1.1" | ||
// Windows: ? | ||
``` | ||
--- | ||
### getTimezone() | ||
Gets the device default timezone. | ||
**Examples** | ||
```js | ||
const timezone = DeviceInfo.getTimezone(); // "Africa/Tunis" | ||
``` | ||
--- | ||
### getTotalDiskCapacity() | ||
Gets full disk storage size, in bytes. | ||
**Examples** | ||
```js | ||
const storageSize = DeviceInfo.getTotalDiskCapacity(); | ||
// Android: 17179869184 | ||
// iOS: 17179869184 | ||
``` | ||
--- | ||
### getTotalMemory() | ||
Gets the device total memory, in bytes. | ||
**Examples** | ||
```js | ||
const totalMemory = DeviceInfo.getTotalMemory(); | ||
// iOS: ? | ||
// Android: 1995018240 | ||
// Windows: ? | ||
``` | ||
--- | ||
### getUniqueID() | ||
Gets the device unique ID. | ||
**Examples** | ||
```js | ||
const uniqueId = DeviceInfo.getUniqueID(); | ||
// iOS: "FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9" | ||
// Android: "dd96dec43fb81c97" | ||
// Windows: ? | ||
``` | ||
**Notes** | ||
> This is IDFV on iOS so it will change if all apps from the current apps vendor have been previously uninstalled. | ||
--- | ||
### getUserAgent() | ||
Gets the device User Agent. | ||
**Examples** | ||
```js | ||
const userAgent = DeviceInfo.getUserAgent(); | ||
// iOS: "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143" | ||
// Android: ? | ||
// Windows: ? | ||
``` | ||
--- | ||
### getVersion() | ||
Gets the application version. | ||
**Examples** | ||
```js | ||
const version = DeviceInfo.getVersion(); | ||
// iOS: "1.0" | ||
// Android: "1.0 | ||
// Windows: ? | ||
``` | ||
--- | ||
### is24Hour() | ||
Tells if the user preference is set to 24-hour format. | ||
**Examples** | ||
```js | ||
const is24Hour = DeviceInfo.is24Hour(); // true | ||
``` | ||
--- | ||
### isEmulator() | ||
Tells if the application is running in an emulator. | ||
**Examples** | ||
```js | ||
const isEmulator = DeviceInfo.isEmulator(); // false | ||
``` | ||
--- | ||
### isPinOrFingerprintSet() | ||
Tells if a PIN number or a fingerprint was set for the device. | ||
**Examples** | ||
```js | ||
DeviceInfo.isPinOrFingerprintSet()(isPinOrFingerprintSet => { | ||
if (!isPinOrFingerprintSet) { | ||
@@ -221,1 +769,22 @@ ... | ||
``` | ||
**Notes** | ||
> * 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. | ||
> * iOS: Not supported for iOS < 9 | ||
--- | ||
### isTablet() | ||
Tells if the device is a tablet. | ||
**Examples** | ||
```js | ||
const isTablet = DeviceInfo.isTablet(); // true | ||
``` | ||
## Release Notes | ||
See the [CHANGELOG.md](https://github.com/rebeccahughes/react-native-device-info/blob/master/CHANGELOG.md). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
127508
36
173
779
2
1