New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-device-info

Package Overview
Dependencies
Maintainers
5
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-device-info - npm Package Compare versions

Comparing version 3.0.0-beta.2 to 3.0.0-beta.3

41

CHANGELOG.md
<!-- markdownlint-disable MD024 MD034 MD033 -->
# Release Notes
## 3.0.0-rc.3
* fix some real android device v2->v3 discrepancies
* BREAKING CHANGE: more capitalization changes for API calls to standardize (see below)
* BREAKING CHANGE: more return value changes to standardize return values (see below)
## 3.0.0-rc.2
* fix all emulator/simulator v2->v3 discrepancies
## 3.0.0-rc.1
* BREAKING CHANGE: Everything returns a Promise now. No more constants (no more explicit async Android constructor)
* BREAKING CHANGE: Renamed getSupportedABIs to getSupportedAbis for consistency with other getXxxAbis methods
* BREAKING CHANGE: all events prefixed with 'RNDeviceInfo_' to future-proof against collisions (https://github.com/react-native-community/react-native-device-info/issues/620)
Each BREAKING CHANGE contains the required information to migrate. The example App.js shows sample usage.
* BREAKING CHANGE: Every API call returns a Promise now (and thus no more Android constructor with async boolean argument)
* This was required to improve module load speed, handle dynamic values, and release the main queue for iOS
* BREAKING CHANGE: Every API call with acronyms ('getIP', 'getABI' etc follows pure camel-case now, e.g. 'getIp', 'getAbi')
* This naming style is a consensus standard. Previously APIs here were half one way half the other. Now they are consistent
* isAirPlaneMode -> isAirplaneMode
* getIPAddress -> getIpAddress
* getMACAddress -> getMACAddress
* getAPILevel -> GetApiLevel
* getBaseOS -> getBaseOs
* getInstanceID -> getInstanceId
* getUniqueID -> getUniqueId
* supportedABIs -> supportedAbis
* BREAKING CHANGE: all events prefixed with 'RNDeviceInfo_' (https://github.com/react-native-community/react-native-device-info/issues/620)
* This is required as event names are a global namespace and collisions are inevitable otherwise
* powerStateDidChange -> RNDeviceInfo_powerStateDidChange
* batteryLevelDidChange -> RNDeviceInfo_batteryLevelDidChange
* batteryLevelIsLow -> RNDeviceInfo_batteryLevelIsLow
* BREAKING CHANGE: Android `getBuildNumber` returns string like iOS (https://github.com/react-native-community/react-native-device-info/pull/648)
* BREAKING CHANGE: remove is24Hour, getTimezone, isAutoTimeZone and isAutoDateAndTime, getDeviceLocale, getDeviceCountry, getPreferredLocales. react-native-localize is superior
* BREAKING CHANGE: remove is24Hour, getTimezone, isAutoTimeZone and isAutoDateAndTime, getDeviceLocale, getDeviceCountry, getPreferredLocales
* This was the result of a survey. It removes API duplication in the react-native-community modules
* Related PR: https://github.com/react-native-community/react-native-localize/pull/65
* Use `yarn add https://github.com/mikehardy/react-native-localize.git#e062f0d2dc3171dc18fdb7b7139d347ad03933dc` to maintain isAutoTimeZone + isAutoDateAndTime until merged
* BREAKING CHANGE: iOS switch deprecated WebView for WebKit / getUserAgent returns Promise (https://github.com/react-native-community/react-native-device-info/pull/757)
* The change from WebView to WebKit was required as the API is being removed from the iOS platform
* BREAKING CHANGE: if an API is platform-specific, all non-implementing platforms will return standard values of -1, false, or 'unknown' depending on return type
* This was how most APIs behaved before but it was not 100% - some returned null or empty string before
* getPhoneNumber sometimes returned null, now it will be 'unknown' if not known
* deprecated: IP-address-related methods deprecated - use @react-native-community/netinfo or react-native-network-info or react-native-carrier-info
* feat: all APIs are now restricted in Javascirpt to the platforms they have full implementations on so the web polyfill is up to date
* feat: 'getAndroidId' on Android returns android.provider.Settings.Secure.ANDROID_ID, read platform docs for usage
* feat: `getUsedMemory` (https://github.com/rebeccahughes/react-native-device-info/pull/356)

@@ -16,0 +49,0 @@ * feat: getDeviceName() without Bluetooth permission on Android (https://github.com/react-native-community/react-native-device-info/issues/735)

15

deviceinfo.d.ts

@@ -20,3 +20,3 @@ // should be imported this way:

declare const _default: {
getUniqueID: () => Promise<string>;
getUniqueId: () => Promise<string>;
getManufacturer: () => Promise<string>;

@@ -37,3 +37,3 @@ getBrand: () => Promise<string>;

getUserAgent: () => Promise<string>;
getInstanceID: () => Promise<string>;
getInstanceId: () => Promise<string>;
getInstallReferrer: () => string | null;

@@ -52,3 +52,3 @@ isEmulator: () => Promise<boolean>;

getType: () => Promise<string>;
getBaseOS: () => Promise<string>;
getBaseOs: () => Promise<string>;
getPreviewSdkInt: () => Promise<number>;

@@ -63,7 +63,8 @@ getSecurityPatch: () => Promise<string>;

getSerialNumber: () => Promise<string>;
getIPAddress: () => Promise<string>;
getAndroidId: () => Promise<string>;
getIpAddress: () => Promise<string>;
getCameraPresence: () => Promise<boolean>;
getMACAddress: () => Promise<string>;
getMacAddress: () => Promise<string>;
getPhoneNumber: () => Promise<string>;
getAPILevel: () => Promise<number>;
getApiLevel: () => Promise<number>;
getCarrier: () => Promise<string>;

@@ -78,3 +79,3 @@ getTotalMemory: () => Promise<number>;

isLandscape: () => Promise<boolean>;
isAirPlaneMode: () => Promise<boolean>;
isAirplaneMode: () => Promise<boolean>;
getDeviceType: () => Promise<DeviceType>;

@@ -81,0 +82,0 @@ supportedAbis: () => Promise<string[]>;

@@ -7,4 +7,5 @@ /**

var RNDeviceInfo = NativeModules.RNDeviceInfo;
var OS = Platform.OS;
if (Platform.OS === 'web' || Platform.OS === 'dom') {
if (OS === 'web' || OS === 'dom') {
RNDeviceInfo = require('./web');

@@ -14,10 +15,5 @@ }

// Produce an error if we don't have the native module
if (
Platform.OS === 'android' ||
Platform.OS === 'ios' ||
Platform.OS === 'web' ||
Platform.OS === 'dom'
) {
if (OS === 'android' || OS === 'ios' || OS === 'web' || OS === 'dom') {
throw new Error(`@react-native-community/react-native-device-info: NativeModule.RNDeviceInfo is null. To fix this issue try these steps:
• Run \`react-native link react-native-device-info\` in the project root.
• For react-native <= 0.59: Run \`react-native link react-native-device-info\` in the project root.
• Rebuild and re-run the app.

@@ -27,4 +23,2 @@ • If you are using CocoaPods on iOS, run \`pod install\` in the \`ios\` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.

}
RNDeviceInfo = require('./default');
}

@@ -358,36 +352,68 @@

export async function getUniqueID() {
return RNDeviceInfo.getUniqueId();
export async function getUniqueId() {
if (OS === 'android' || OS === 'ios' || OS === 'windows') {
return RNDeviceInfo.getUniqueId();
}
return Promise.resolve('unknown');
}
export async function getInstanceID() {
return RNDeviceInfo.getInstanceId();
export async function getInstanceId() {
if (OS === 'android') {
return RNDeviceInfo.getInstanceId();
} else {
return Promise.resolve('unknown');
}
}
export async function getSerialNumber() {
return RNDeviceInfo.getSerialNumber();
if (OS === 'android') {
return RNDeviceInfo.getSerialNumber();
}
return Promise.resolve('unknown');
}
export async function getIPAddress() {
return RNDeviceInfo.getIpAddress();
export async function getAndroidId() {
if (OS === 'android') {
return RNDeviceInfo.getAndroidId();
}
return Promise.resolve('unknown');
}
export async function getIpAddress() {
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getIpAddress();
}
return Promise.resolve('unknown');
}
export async function getCameraPresence() {
return RNDeviceInfo.getCameraPresence();
if (OS === 'android' || OS === 'windows') {
return RNDeviceInfo.getCameraPresence();
}
return Promise.resolve(false);
}
export async function getMACAddress() {
return RNDeviceInfo.getMacAddress();
export async function getMacAddress() {
if (OS === 'android' || OS === 'macos') {
return RNDeviceInfo.getMacAddress();
}
return Promise.resolve('unknown');
}
export async function getDeviceId() {
return RNDeviceInfo.getDeviceId();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getDeviceId();
}
return Promise.resolve('unknown');
}
export async function getManufacturer() {
return RNDeviceInfo.getSystemManufacturer();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getSystemManufacturer();
}
return Promise.resolve('unknown');
}
export async function getModel() {
if (Platform.OS === 'ios') {
if (OS === 'ios') {
var deviceName;

@@ -411,41 +437,70 @@ var deviceId = await RNDeviceInfo.getDeviceId();

return Promise.resolve(deviceName);
} else {
}
if (OS === 'android' || OS === 'windows') {
return RNDeviceInfo.getModel();
}
return Promise.resolve('unknown');
}
export async function getBrand() {
return RNDeviceInfo.getBrand();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getBrand();
}
return Promise.resolve('unknown');
}
export async function getSystemName() {
return RNDeviceInfo.getSystemName();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getSystemName();
}
return Promise.resolve('unknown');
}
export async function getSystemVersion() {
return RNDeviceInfo.getSystemVersion();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getSystemVersion();
}
return Promise.resolve('unknown');
}
export async function getBuildId() {
return RNDeviceInfo.getBuildId();
if (OS === 'android' || OS === 'macos') {
return RNDeviceInfo.getBuildId();
}
return Promise.resolve('unknown');
}
export async function getAPILevel() {
return RNDeviceInfo.getApiLevel();
export async function getApiLevel() {
if (OS === 'android') {
return RNDeviceInfo.getApiLevel();
}
return Promise.resolve(-1);
}
export async function getBundleId() {
return RNDeviceInfo.getBundleId();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getBundleId();
}
return Promise.resolve('unknown');
}
export async function getApplicationName() {
return RNDeviceInfo.getAppName();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getAppName();
}
return Promise.resolve('unknown');
}
export async function getBuildNumber() {
return RNDeviceInfo.getBuildNumber();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getBuildNumber();
}
return Promise.resolve('unknown');
}
export async function getVersion() {
return RNDeviceInfo.getAppVersion();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getAppVersion();
}
return Promise.resolve('unknown');
}

@@ -458,83 +513,146 @@

export async function getDeviceName() {
return RNDeviceInfo.getDeviceName();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getDeviceName();
}
return Promise.resolve('unknown');
}
export async function getUsedMemory() {
return RNDeviceInfo.getUsedMemory();
if (OS === 'android' || OS === 'macos') {
return RNDeviceInfo.getUsedMemory();
}
return Promise.resolve(-1);
}
export async function getUserAgent() {
return RNDeviceInfo.getUserAgent();
if (OS === 'android' || OS === 'macos' || OS === 'web') {
return RNDeviceInfo.getUserAgent();
}
return Promise.resolve('unknown');
}
export async function getFontScale() {
return RNDeviceInfo.getFontScale();
if (OS === 'android' || OS === 'macos') {
return RNDeviceInfo.getFontScale();
}
return Promise.resolve('unknown');
}
export async function getBootloader() {
return RNDeviceInfo.getBootloader();
if (OS === 'android') {
return RNDeviceInfo.getBootloader();
}
return Promise.resolve('unknown');
}
export async function getDevice() {
return RNDeviceInfo.getDevice();
if (OS === 'android') {
return RNDeviceInfo.getDevice();
}
return Promise.resolve('unknown');
}
export async function getDisplay() {
return RNDeviceInfo.getDisplay();
if (OS === 'android') {
return RNDeviceInfo.getDisplay();
}
return Promise.resolve('unknown');
}
export async function getFingerprint() {
return RNDeviceInfo.getFingerprint();
if (OS === 'android') {
return RNDeviceInfo.getFingerprint();
}
return Promise.resolve('unknown');
}
export async function getHardware() {
return RNDeviceInfo.getHardware();
if (OS === 'android') {
return RNDeviceInfo.getHardware();
}
return Promise.resolve('unknown');
}
export async function getHost() {
return RNDeviceInfo.getHost();
if (OS === 'android') {
return RNDeviceInfo.getHost();
}
return Promise.resolve('unknown');
}
export async function getProduct() {
return RNDeviceInfo.getProduct();
if (OS === 'android') {
return RNDeviceInfo.getProduct();
}
return Promise.resolve('unknown');
}
export async function getTags() {
return RNDeviceInfo.getTags();
if (OS === 'android') {
return RNDeviceInfo.getTags();
}
return Promise.resolve('unknown');
}
export async function getType() {
return RNDeviceInfo.getType();
if (OS === 'android') {
return RNDeviceInfo.getType();
}
return Promise.resolve('unknown');
}
export async function getBaseOS() {
return RNDeviceInfo.getBaseOS();
export async function getBaseOs() {
if (OS === 'android') {
return RNDeviceInfo.getBaseOs();
}
return Promise.resolve('unknown');
}
export async function getPreviewSdkInt() {
return RNDeviceInfo.getPreviewSdkInt();
if (OS === 'android') {
return RNDeviceInfo.getPreviewSdkInt();
}
return Promise.resolve('unknown');
}
export async function getSecurityPatch() {
return RNDeviceInfo.getSecurityPatch();
if (OS === 'android') {
return RNDeviceInfo.getSecurityPatch();
}
return Promise.resolve('unknown');
}
export async function getCodename() {
return RNDeviceInfo.getCodename();
if (OS === 'android') {
return RNDeviceInfo.getCodename();
}
return Promise.resolve('unknown');
}
export async function getIncremental() {
return RNDeviceInfo.getIncremental();
if (OS === 'android') {
return RNDeviceInfo.getIncremental();
}
return Promise.resolve('unknown');
}
export async function isEmulator() {
return RNDeviceInfo.isEmulator();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.isEmulator();
}
return Promise.resolve(false);
}
export async function isTablet() {
return RNDeviceInfo.isTablet();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.isTablet();
}
return Promise.resolve(false);
}
export async function isPinOrFingerprintSet() {
return RNDeviceInfo.isPinOrFingerprintSet();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.isPinOrFingerprintSet();
}
return Promise.resolve(false);
}

@@ -555,46 +673,83 @@

export async function getFirstInstallTime() {
return RNDeviceInfo.getFirstInstallTime();
if (OS === 'android' || OS === 'windows') {
return RNDeviceInfo.getFirstInstallTime();
}
return Promise.resolve(-1);
}
export async function getInstallReferrer() {
return RNDeviceInfo.getInstallReferrer();
if (OS === 'android') {
return RNDeviceInfo.getInstallReferrer();
}
return Promise.resolve('unknown');
}
export async function getLastUpdateTime() {
return RNDeviceInfo.getLastUpdateTime();
if (OS === 'android') {
return RNDeviceInfo.getLastUpdateTime();
}
return Promise.resolve(-1);
}
export async function getPhoneNumber() {
return RNDeviceInfo.getPhoneNumber();
if (OS === 'android') {
return RNDeviceInfo.getPhoneNumber();
}
return Promise.resolve('unknown');
}
export async function getCarrier() {
return RNDeviceInfo.getCarrier();
if (OS === 'android' || OS === 'macos') {
return RNDeviceInfo.getCarrier();
}
return Promise.resolve('unknown');
}
export async function getTotalMemory() {
return RNDeviceInfo.getTotalMemory();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getTotalMemory();
}
return Promise.resolve(-1);
}
export async function getMaxMemory() {
return RNDeviceInfo.getMaxMemory();
if (OS === 'android' || OS === 'windows') {
return RNDeviceInfo.getMaxMemory();
}
return Promise.resolve(-1);
}
export async function getTotalDiskCapacity() {
return RNDeviceInfo.getTotalDiskCapacity();
if (OS === 'android' || OS === 'macos') {
return RNDeviceInfo.getTotalDiskCapacity();
}
return Promise.resolve(-1);
}
export async function getFreeDiskStorage() {
return RNDeviceInfo.getFreeDiskStorage();
if (OS === 'android' || OS === 'macos') {
return RNDeviceInfo.getFreeDiskStorage();
}
return Promise.resolve(-1);
}
export async function getBatteryLevel() {
return RNDeviceInfo.getBatteryLevel();
if (OS === 'android' || OS === 'macos' || OS === 'windows') {
return RNDeviceInfo.getBatteryLevel();
}
return Promise.resolve(-1);
}
export async function getPowerState() {
return RNDeviceInfo.getPowerState();
if (OS === 'macos') {
return RNDeviceInfo.getPowerState();
}
return Promise.resolve({});
}
export async function isBatteryCharging() {
return RNDeviceInfo.isBatteryCharging();
if (OS === 'android' || OS === 'macos') {
return RNDeviceInfo.isBatteryCharging();
}
return Promise.resolve(false);
}

@@ -607,45 +762,73 @@

export async function isAirPlaneMode() {
return RNDeviceInfo.isAirPlaneMode();
export async function isAirplaneMode() {
if (OS === 'android') {
return RNDeviceInfo.isAirplaneMode();
}
return Promise.resolve(false);
}
export async function getDeviceType() {
return RNDeviceInfo.getDeviceType();
if (OS === 'android' || OS === 'macos') {
return RNDeviceInfo.getDeviceType();
}
return Promise.resolve('unknown');
}
export async function supportedAbis() {
return RNDeviceInfo.getSupportedAbis();
if (OS === 'android' || OS === 'macos') {
return RNDeviceInfo.getSupportedAbis();
}
return Promise.resolve([]);
}
export async function supported32BitAbis() {
return RNDeviceInfo.getSupported32BitAbis();
if (OS === 'android') {
return RNDeviceInfo.getSupported32BitAbis();
}
return Promise.resolve([]);
}
export async function supported64BitAbis() {
return RNDeviceInfo.getSupported64BitAbis();
if (OS === 'android') {
return RNDeviceInfo.getSupported64BitAbis();
}
return Promise.resolve([]);
}
export async function hasSystemFeature(feature) {
return RNDeviceInfo.hasSystemFeature(feature);
if (OS === 'android') {
return RNDeviceInfo.hasSystemFeature(feature);
}
return Promise.resolve(false);
}
export async function getSystemAvailableFeatures() {
return RNDeviceInfo.getSystemAvailableFeatures();
if (OS === 'android') {
return RNDeviceInfo.getSystemAvailableFeatures();
}
return Promise.resolve([]);
}
export async function isLocationEnabled() {
return RNDeviceInfo.isLocationEnabled();
if (OS === 'android' || OS === 'macos') {
return RNDeviceInfo.isLocationEnabled();
}
return Promise.resolve(false);
}
export async function getAvailableLocationProviders() {
return RNDeviceInfo.getAvailableLocationProviders();
if (OS === 'android' || OS === 'macos') {
return RNDeviceInfo.getAvailableLocationProviders();
}
return Promise.resolve({});
}
export default {
getUniqueID,
getInstanceID,
getUniqueId,
getInstanceId,
getSerialNumber,
getIPAddress,
getAndroidId,
getIpAddress,
getCameraPresence,
getMACAddress,
getMacAddress,
getDeviceId,

@@ -658,3 +841,3 @@ getManufacturer,

getBuildId,
getAPILevel,
getApiLevel,
getBundleId,

@@ -678,3 +861,3 @@ getApplicationName,

getType,
getBaseOS,
getBaseOs,
getPreviewSdkInt,

@@ -701,3 +884,3 @@ getSecurityPatch,

isLandscape,
isAirPlaneMode,
isAirplaneMode,
getDeviceType,

@@ -704,0 +887,0 @@ supportedAbis,

{
"name": "react-native-device-info",
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.3",
"description": "Get device information using react-native",

@@ -13,6 +13,6 @@ "main": "deviceinfo.js",

"analyze": "yarn ts-check && yarn flow-check",
"dev-sync": "cp -r deviceinfo* *podspec default windows web android ios example/node_modules/react-native-device-info/",
"dev-sync": "cp -r deviceinfo* *podspec windows web android ios example/node_modules/react-native-device-info/",
"flow-check": "npx flow check-contents < deviceinfo.js.flow",
"lint": "npx eslint ./ --ignore-pattern example --ignore-pattern node_modules --fix --quiet",
"shipit": "np --no-yarn",
"shipit": "np",
"ts-check": "npx tsc deviceinfo.d.ts --noEmit",

@@ -61,3 +61,3 @@ "precommit": "lint-staged && yarn analyze"

"flow-bin": "^0.106.3",
"husky": "^3.0.2",
"husky": "^3.0.5",
"lint-staged": "^9.2.1",

@@ -64,0 +64,0 @@ "np": "^5.0.3",

@@ -260,3 +260,3 @@ <!-- markdownlint-disable MD024 MD034 MD033 -->

import { getUniqueID, getManufacturer } from 'react-native-device-info';
import { getUniqueId, getManufacturer } from 'react-native-device-info';
```

@@ -266,71 +266,74 @@

| Method | Return Type |  iOS | Android | Windows | Since |
| ----------------------------------------------------------------- | ------------------- | :--: | :-----: | :-----: | ------ |
| [getAPILevel()](#getapilevel) | `Promise<number>` | ❌ | ✅ | ❌ | 0.12.0 |
| [getApplicationName()](#getapplicationname) | `Promise<string>` | ✅ | ✅ | ✅ | 0.14.0 |
| [getBaseOS()](#getbaseOS) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getBatteryLevel()](#getbatterylevel) | `Promise<number>` | ✅ | ✅ | ✅ | 0.18.0 |
| [getBootloader()](#getbootloader) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getBrand()](#getbrand) | `Promise<string>` | ✅ | ✅ | ✅ | 0.9.3 |
| [getBuildNumber()](#getbuildnumber) | `Promise<string>` | ✅ | ✅ | ✅ | ? |
| [getBundleId()](#getbundleid) | `Promise<string>` | ✅ | ✅ | ✅ | ? |
| [getCameraPresence()](#getcamerapresence) | `Promise<boolean>` | ❌ | ✅ | ✅ | ? |
| [getCarrier()](#getcarrier) | `Promise<string>` | ✅ | ✅ | ❌ | 0.13.0 |
| [getCodename()](#getcodename) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getDevice()](#getdevice) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getDeviceId()](#getdeviceid) | `Promise<string>` | ✅ | ✅ | ✅ | 0.5.0 |
| [getDisplay()](#getdisplay) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getDeviceName()](#getdevicename) | `Promise<string>` | ✅ | ✅ | ✅ | ? |
| [getFirstInstallTime()](#getfirstinstalltime) | `Promise<number>` | ❌ | ✅ | ✅ | 0.12.0 |
| [getFingerprint()](#getfingerprint) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getFontScale()](#getfontscale) | `Promise<number>` | ✅ | ✅ | ❌ | 0.15.0 |
| [getFreeDiskStorage()](#getfreediskstorage) | `Promise<number>` | ✅ | ✅ | ❌ | 0.15.0 |
| [getHardware()](#gethardware) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getHost()](#gethost) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getIPAddress()](#getipaddress) | `Promise<string>` | ✅ | ✅ | ✅ | 0.12.0 |
| [getIncremental()](#getincremental) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getInstallReferrer()](#getinstallreferrer) | `Promise<string>` | ❌ | ✅ | ❌ | 0.19.0 |
| [getInstanceID()](#getinstanceid) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getLastUpdateTime()](#getlastupdatetime) | `Promise<number>` | ❌ | ✅ | ❌ | 0.12.0 |
| [getMACAddress()](#getmacaddress) | `Promise<string>` | ✅ | ✅ | ❌ | 0.12.0 |
| [getManufacturer()](#getmanufacturer) | `Promise<string>` | ✅ | ✅ | ✅ | ? |
| [getMaxMemory()](#getmaxmemory) | `Promise<number>` | ❌ | ✅ | ✅ | 0.14.0 |
| [getModel()](#getmodel) | `Promise<string>` | ✅ | ✅ | ✅ | ? |
| [getPhoneNumber()](#getphonenumber) | `Promise<string>` | ❌ | ✅ | ❌ | 0.12.0 |
| [getPowerState()](#getpowerstate) | `Promise<object>` | ✅ | ❌ | ❌ | |
| [getProduct()](#getproduct) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getPreviewSdkInt()](#getPreviewSdkInt) | `Promise<number>` | ❌ | ✅ | ❌ | ? |
| [getReadableVersion()](#getreadableversion) | `Promise<string>` | ✅ | ✅ | ✅ | ? |
| [getSerialNumber()](#getserialnumber) | `Promise<string>` | ❌ | ✅ | ❌ | 0.12.0 |
| [getSecurityPatch()](#getsecuritypatch) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getSystemName()](#getsystemname) | `Promise<string>` | ✅ | ✅ | ✅ | ? |
| [getSystemVersion()](#getsystemversion) | `Promise<string>` | ✅ | ✅ | ✅ | ? |
| [getBuildId()](#getbuildid) | `Promise<string>` | ✅ | ✅ | ❌ | ? |
| [getTags()](#gettags) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getType()](#gettype) | `Promise<string>` | ❌ | ✅ | ❌ | ? |
| [getTotalDiskCapacity()](#gettotaldiskcapacity) | `Promise<number>` | ✅ | ✅ | ❌ | 0.15.0 |
| [getTotalMemory()](#gettotalmemory) | `Promise<number>` | ✅ | ✅ | ❌ | 0.14.0 |
| [getUniqueID()](#getuniqueid) | `Promise<string>` | ✅ | ✅ | ✅ | ? |
| [getUsedMemory()](#getusedmemory) | `Promise<number>` | ✅ | ✅ | ❌ | 3.0.0 |
| [getUserAgent()](#getuseragent) | `Promise<string>` | ✅ | ✅ | ❌ | 0.7.0 |
| [getVersion()](#getversion) | `Promise<string>` | ✅ | ✅ | ✅ | ? |
| [isAirPlaneMode()](#isairplanemode) | `Promise<boolean>` | ❌ | ✅ | ❌ | 0.25.0 |
| [isBatteryCharging()](#isbatterycharging) | `Promise<boolean>` | ✅ | ✅ | ❌ | 0.27.0 |
| [isEmulator()](#isemulator) | `Promise<boolean>` | ✅ | ✅ | ✅ | ? |
| [isPinOrFingerprintSet()](#ispinorfingerprintset) | `Promise<boolean>` | ✅ | ✅ | ✅ | 0.10.1 |
| [isTablet()](#istablet) | `Promise<boolean>` | ✅ | ✅ | ✅ | ? |
| [hasNotch()](#hasNotch) | `Promise<boolean>` | ✅ | ✅ | ✅ | 0.23.0 |
| [isLandscape()](#isLandscape) | `Promise<boolean>` | ✅ | ✅ | ✅ | 0.24.0 |
| [getDeviceType()](#getDeviceType) | `Promise<string>` | ✅ | ✅ | ❌ | ? |
| [supported32BitAbis()](#supported32BitAbis) | `Promise<string[]>` | ❌ | ✅ | ❌ | ? |
| [supported64BitAbis()](#supported64BitAbis) | `Promise<string[]>` | ❌ | ✅ | ❌ | ? |
| [supportedAbis()](#supportedAbis) | `Promise<string[]>` | ✅ | ✅ | ❌ | 1.1.0 |
| [hasSystemFeature()](#hassystemfeaturefeature) | `Promise<boolean>` | ❌ | ✅ | ❌ | ? |
| [getSystemAvailableFeatures()](#getSystemAvailableFeatures) | `Promise<string[]>` | ❌ | ✅ | ❌ | ? |
| [isLocationEnabled()](#isLocationEnabled) | `Promise<boolean>` | ✅ | ✅ | ❌ | ? |
| [getAvailableLocationProviders()](#getAvailableLocationProviders) | `Promise<Object>` | ✅ | ✅ | ❌ | ? |
Note that many APIs are platform-specific. If there is no implementation for a platform, then the "default" return values you will receive are 'unknown' for string, '-1' for number, and 'false' for boolean. Arrays and Objects will be empty ('[]' and '{}' respectively).
| Method | Return Type | iOS | Android | Windows |
| ----------------------------------------------------------------- | ------------------- | :-: | :-----: | :-----: |
| [getAndroidId()](#getandroidid) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getApiLevel()](#getapilevel) | `Promise<number>` | ❌ | ✅ | ❌ |
| [getApplicationName()](#getapplicationname) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getAvailableLocationProviders()](#getAvailableLocationProviders) | `Promise<Object>` | ✅ | ✅ | ❌ |
| [getBaseOs()](#getbaseOs) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getBuildId()](#getbuildid) | `Promise<string>` | ✅ | ✅ | ❌ |
| [getBatteryLevel()](#getbatterylevel) | `Promise<number>` | ✅ | ✅ | ✅ |
| [getBootloader()](#getbootloader) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getBrand()](#getbrand) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getBuildNumber()](#getbuildnumber) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getBundleId()](#getbundleid) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getCameraPresence()](#getcamerapresence) | `Promise<boolean>` | ❌ | ✅ | ✅ |
| [getCarrier()](#getcarrier) | `Promise<string>` | ✅ | ✅ | ❌ |
| [getCodename()](#getcodename) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getDevice()](#getdevice) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getDeviceId()](#getdeviceid) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getDeviceType()](#getDeviceType) | `Promise<string>` | ✅ | ✅ | ❌ |
| [getDisplay()](#getdisplay) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getDeviceName()](#getdevicename) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getFirstInstallTime()](#getfirstinstalltime) | `Promise<number>` | ❌ | ✅ | ✅ |
| [getFingerprint()](#getfingerprint) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getFontScale()](#getfontscale) | `Promise<number>` | ✅ | ✅ | ❌ |
| [getFreeDiskStorage()](#getfreediskstorage) | `Promise<number>` | ✅ | ✅ | ❌ |
| [getHardware()](#gethardware) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getHost()](#gethost) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getIpAddress()](#getipaddress) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getIncremental()](#getincremental) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getInstallReferrer()](#getinstallreferrer) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getInstanceId()](#getinstanceid) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getLastUpdateTime()](#getlastupdatetime) | `Promise<number>` | ❌ | ✅ | ❌ |
| [getMacAddress()](#getmacaddress) | `Promise<string>` | ✅ | ✅ | ❌ |
| [getManufacturer()](#getmanufacturer) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getMaxMemory()](#getmaxmemory) | `Promise<number>` | ❌ | ✅ | ✅ |
| [getModel()](#getmodel) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getPhoneNumber()](#getphonenumber) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getPowerState()](#getpowerstate) | `Promise<object>` | ✅ | ❌ | ❌ |
| [getProduct()](#getproduct) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getPreviewSdkInt()](#getPreviewSdkInt) | `Promise<number>` | ❌ | ✅ | ❌ |
| [getReadableVersion()](#getreadableversion) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getSerialNumber()](#getserialnumber) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getSecurityPatch()](#getsecuritypatch) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getSystemAvailableFeatures()](#getSystemAvailableFeatures) | `Promise<string[]>` | ❌ | ✅ | ❌ |
| [getSystemName()](#getsystemname) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getSystemVersion()](#getsystemversion) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getTags()](#gettags) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getType()](#gettype) | `Promise<string>` | ❌ | ✅ | ❌ |
| [getTotalDiskCapacity()](#gettotaldiskcapacity) | `Promise<number>` | ✅ | ✅ | ❌ |
| [getTotalMemory()](#gettotalmemory) | `Promise<number>` | ✅ | ✅ | ❌ |
| [getUniqueId()](#getuniqueid) | `Promise<string>` | ✅ | ✅ | ✅ |
| [getUsedMemory()](#getusedmemory) | `Promise<number>` | ✅ | ✅ | ❌ |
| [getUserAgent()](#getuseragent) | `Promise<string>` | ✅ | ✅ | ❌ |
| [getVersion()](#getversion) | `Promise<string>` | ✅ | ✅ | ✅ |
| [hasNotch()](#hasNotch) | `Promise<boolean>` | ✅ | ✅ | ✅ |
| [hasSystemFeature()](#hassystemfeaturefeature) | `Promise<boolean>` | ❌ | ✅ | ❌ |
| [isAirPlaneMode()](#isairplanemode) | `Promise<boolean>` | ❌ | ✅ | ❌ |
| [isBatteryCharging()](#isbatterycharging) | `Promise<boolean>` | ✅ | ✅ | ❌ |
| [isEmulator()](#isemulator) | `Promise<boolean>` | ✅ | ✅ | ✅ |
| [isLandscape()](#isLandscape) | `Promise<boolean>` | ✅ | ✅ | ✅ |
| [isLocationEnabled()](#isLocationEnabled) | `Promise<boolean>` | ✅ | ✅ | ❌ |
| [isPinOrFingerprintSet()](#ispinorfingerprintset) | `Promise<boolean>` | ✅ | ✅ | ✅ |
| [isTablet()](#istablet) | `Promise<boolean>` | ✅ | ✅ | ✅ |
| [supported32BitAbis()](#supported32BitAbis) | `Promise<string[]>` | ❌ | ✅ | ❌ |
| [supported64BitAbis()](#supported64BitAbis) | `Promise<string[]>` | ❌ | ✅ | ❌ |
| [supportedAbis()](#supportedAbis) | `Promise<string[]>` | ✅ | ✅ | ❌ |
---
### getAPILevel()
### getApiLevel()

@@ -342,3 +345,3 @@ Gets the API level.

```js
DeviceInfo.getAPILevel().then(apiLevel => {
DeviceInfo.getApiLevel().then(apiLevel => {
// iOS: ?

@@ -356,2 +359,16 @@ // Android: 25

### getAndroidId()
Gets the ANDROID_ID. See [API documentation](https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID) for appropriate use.
#### Examples
```js
DeviceInfo.getAndroidId().then(androidId => {
// androidId here
});
```
---
### getApplicationName()

@@ -371,3 +388,3 @@

### getBaseOS()
### getBaseOs()

@@ -379,3 +396,3 @@ The base OS build the product is based on.

```js
DeviceInfo.getBaseOS().then(baseOS => {
DeviceInfo.getBaseOs().then(baseOs => {
// "Windows", "Android" etc

@@ -688,3 +705,3 @@ });

### getIPAddress()
### getIpAddress()

@@ -697,3 +714,3 @@ **Deprecated** Gets the device current IP address. (of wifi only)

```js
DeviceInfo.getIPAddress().then(ip => {
DeviceInfo.getIpAddress().then(ip => {
// "92.168.32.44"

@@ -742,3 +759,3 @@ });

### getInstanceID()
### getInstanceId()

@@ -750,3 +767,3 @@ Gets the application instance ID.

```js
DeviceInfo.getInstanceID().then(instanceId => {
DeviceInfo.getInstanceId().then(instanceId => {
// Android: ?

@@ -776,3 +793,3 @@ });

### getMACAddress()
### getMacAddress()

@@ -784,3 +801,3 @@ Gets the network adapter MAC address.

```js
DeviceInfo.getMACAddress().then(mac => {
DeviceInfo.getMacAddress().then(mac => {
// "E5:12:D8:E5:69:97"

@@ -935,3 +952,3 @@ });

Gets the device serial number.
Gets the device serial number. Will be 'unknown' in almost all cases [unless you have a privileged app and you know what you're doing](https://developer.android.com/reference/android/os/Build.html#getSerial()).

@@ -942,5 +959,5 @@ #### Examples

DeviceInfo.getSerialNumber().then(serialNumber => {
// iOS: undefined
// Android: ?
// Windows: ?
// iOS: unknown
// Android: ? (maybe a serial number, if your app is privileged)
// Windows: unknown
});

@@ -1071,5 +1088,8 @@ ```

### getUniqueID()
### getUniqueId()
Gets the device unique ID.
Gets the device unique ID.
On Android it is currently identical to getAndroidId() in this module
On iOS it uses the DeviceUID uid identifier
On Windows it uses Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation.id

@@ -1079,3 +1099,3 @@ #### Examples

```js
DeviceInfo.getUniqueID().then(uniqueId => {
DeviceInfo.getUniqueId().then(uniqueId => {
// iOS: "FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9"

@@ -1142,5 +1162,5 @@ // Android: "dd96dec43fb81c97"

### isAirPlaneMode()
### isAirplaneMode()
Tells if the device is in AirPlaneMode.
Tells if the device is in Airplane Mode.

@@ -1150,3 +1170,3 @@ #### Examples

```js
DeviceInfo.isAirPlaneMode().then(airPlaneModeOn => {
DeviceInfo.isAirplaneMode().then(airplaneModeOn => {
// false

@@ -1382,3 +1402,3 @@ });

### batteryLevelDidChange
### RNDeviceInfo_batteryLevelDidChange

@@ -1400,3 +1420,3 @@ Fired when the battery level changes; sent no more frequently than once per minute.

### batteryLevelIsLow
### RNDeviceInfo_batteryLevelIsLow

@@ -1418,3 +1438,3 @@ Fired when the battery drops below 20%.

### powerStateDidChange
### RNDeviceInfo_powerStateDidChange

@@ -1421,0 +1441,0 @@ Fired when the battery state changes, for example when the device enters charging mode or is unplugged.

/**
* react-native-web empty polyfill.
*/
var RNDeviceInfo = require('../default');
RNDeviceInfo.userAgent = window.navigator.userAgent;
module.exports = RNDeviceInfo;
module.exports = {
getUserAgent: () => {
return Promise.resolve(window.navigator.userAgent);
},
};

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc