Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-native-device-info

Get device information using react-native

react-component, react-native, ios, android, windows, device, events, cocoapod

readme

react-native-device-info

npm version npm total downloads npm monthly downloads npm weekly downloads

Device Information for React Native.

TOC

v6 to v7 upgrade

Your iOS Podfile will need to move to an iOS 10 minimum. v7 of this module no longer supports iOS9.

Installation

Using npm:

npm install --save react-native-device-info

or using yarn:

yarn add react-native-device-info

Proguard

If you want to use Install Referrer tracking, you will need to add this config to your Proguard config

-keep class com.android.installreferrer.api.** {
  *;
}

If you are experiencing issues with hasGms() on your release apks, please add the following rule to your Proguard config

-keep class com.google.android.gms.common.** {*;}

AndroidX Support

This module defaults to AndroidX you should configure your library versions similar to this in your android/build.gradle file's "ext" block

<summary>Android</summary>
...
  ext {
    // dependency versions

    We have 3 options for deviceId:
    //Option 1 (latest):
    firebaseIidVersion = "19.0.1" // default: "19.0.1"
    //Option 2 (legacy GooglePlay dependency but using AndroidX):
    googlePlayServicesIidVersion = "17.0.0" // default: "17.0.0" - AndroidX
    //Option 3 (legacy GooglePlay dependency before AndroidX):
    googlePlayServicesIidVersion = "16.0.1"


    //include as needed:
    compileSdkVersion = "28" // default: 28 (28 is required for AndroidX)
    targetSdkVersion = "28" // default: 28 (28 is required for AndroidX)
    supportLibVersion = '1.0.2' // Use '28.0.0' or don't specify for old libraries, '1.0.2' or similar for AndroidX
    mediaCompatVersion = '1.0.1' // Do not specify if using old libraries, specify '1.0.1' or similar for androidx.media:media dependency
    supportV4Version = '1.0.0' // Do not specify if using old libraries, specify '1.0.0' or similar for androidx.legacy:legacy-support-v4 dependency
  }
...

If you need non-AndroidX you will need to use the jetifier package in reverse mode, documentation available with that package.

Linking

Linking in native modules is a frequent source of trouble for new react-native developers, resulting in errors like "RNDeviceInfo is null" etc. For this reason automatic linking was implemented, and it should be used in your project.

Automatic linking is supported for all platforms (even windows on React native >= 0.63!)

Previous versions need to do manual linking. No support is offered for these previous react-native versions but you may refer to older versions of this README if you like. Upgrade to modern versions of react-native. Use upgrade-helper tool on the internet if needed.

Usage

import DeviceInfo from 'react-native-device-info';

// or ES6+ destructured imports

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

API

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).

Most APIs return a Promise but also have a corresponding API with Sync on the end that operates synchronously. For example, you may prefer to call isCameraPresentSync() during your app bootstrap to avoid async calls during the first parts of app startup.

Note about getUserAgentSync

While the asynchronous method getUserAgent is available on both platforms, getUserAgentSync is only supported on Android.

The example app in this repository shows an example usage of every single API, consult the example app if you have questions, and if you think you see a problem make sure you can reproduce it using the example app before reporting it, thank you.

Method Return Type iOS Android Windows Web visionOS
getAndroidId() Promise<string>
getApiLevel() Promise<number>
getApplicationName() string
getAvailableLocationProviders() Promise<Object>
getBaseOs() Promise<string>
getBuildId() Promise<string>
getBatteryLevel() Promise<number>
getBootloader() Promise<string>
getBrand() string
getBuildNumber() string
getBundleId() string
isCameraPresent() Promise<boolean>
getCarrier() Promise<string>
getCodename() Promise<string>
getDevice() Promise<string>
getDeviceId() string
getDeviceType() string
getDisplay() Promise<string>
getDeviceName() Promise<string>
getDeviceToken() Promise<string>
getFirstInstallTime() Promise<number>
getFingerprint() Promise<string>
getFontScale() Promise<number>
getFreeDiskStorage() Promise<number>
getFreeDiskStorageOld() Promise<number>
getHardware() Promise<string>
getHost() Promise<string>
getHostNames() Promise<string[]>
getIpAddress() Promise<string>
getIncremental() Promise<string>
getInstallerPackageName() Promise<string>
getInstallReferrer() Promise<string>
getInstanceId() Promise<string>
getLastUpdateTime() Promise<number>
getMacAddress() Promise<string>
getManufacturer() Promise<string>
getMaxMemory() Promise<number>
getModel() string
getPowerState() Promise<object>
getProduct() Promise<string>
getPreviewSdkInt() Promise<number>
getReadableVersion() string
getSerialNumber() Promise<string>
getSecurityPatch() Promise<string>
getStartupTime() Promise<number>
getSystemAvailableFeatures() Promise<string[]>
getSystemName() string
getSystemVersion() string
getTags() Promise<string>
getType() Promise<string>
getTotalDiskCapacity() Promise<number>
getTotalDiskCapacityOld() Promise<number>
getTotalMemory() Promise<number>
getUniqueId() Promise<string>
getUsedMemory() Promise<number>
getUserAgent() Promise<string>
getUserAgentSync() string
getVersion() string
getBrightness() Promise<number>
hasGms() Promise<boolean>
hasHms() Promise<boolean>
hasNotch() boolean
hasDynamicIsland() boolean
hasSystemFeature() Promise<boolean>
isAirplaneMode() Promise<boolean>
isBatteryCharging() Promise<boolean>
isEmulator() Promise<boolean>
isKeyboardConnected() Promise<bool>
isLandscape() Promise<boolean>
isLocationEnabled() Promise<boolean>
isMouseConnected() Promise<bool>
isHeadphonesConnected() Promise<boolean>
isWiredHeadphonesConnected() Promise<boolean>
isBluetoothHeadphonesConnected() Promise<boolean>
isPinOrFingerprintSet() Promise<boolean>
isTablet() boolean
isLowRamDevice() boolean
isDisplayZoomed() boolean
isTabletMode() Promise<bool>
supported32BitAbis() Promise<string[]>
supported64BitAbis() Promise<string[]>
supportedAbis() Promise<string[]>
syncUniqueId() Promise<string>
getSupportedMediaTypeList() Promise<string[]>

getApiLevel()

Gets the API level.

Examples

DeviceInfo.getApiLevel().then((apiLevel) => {
  // iOS: ?
  // Android: 25
  // Windows: ?
});

Notes

See API Levels


getAndroidId()

Gets the ANDROID_ID. See API documentation for appropriate use.

Examples

DeviceInfo.getAndroidId().then((androidId) => {
  // androidId here
});

getApplicationName()

Gets the application name.

Examples

let appName = DeviceInfo.getApplicationName();
// AwesomeApp

getBaseOs()

The base OS build the product is based on.

Examples

DeviceInfo.getBaseOs().then((baseOs) => {
  // "Windows", "Android" etc
});

getBatteryLevel()

Gets the battery level of the device as a float comprised between 0 and 1.

Examples

DeviceInfo.getBatteryLevel().then((batteryLevel) => {
  // 0.759999
});

Notes

To be able to get actual battery level enable battery monitoring mode for application. Add this code:

[UIDevice currentDevice].batteryMonitoringEnabled = true;

to AppDelegate.m application:didFinishLaunchingWithOptions:

Returns -1 on the iOS Simulator


getBootloader()

The system bootloader version number.

Examples

DeviceInfo.getBootloader().then((bootloader) => {
  // "mw8998-002.0069.00"
});

getBrand()

Gets the device brand.

Examples

let brand = DeviceInfo.getBrand();
// iOS: "Apple"
// Android: "xiaomi"
// Windows: ?

getBuildNumber()

Gets the application build number.

Examples

let buildNumber = DeviceInfo.getBuildNumber();
// iOS: "89"
// Android: "4"
// Windows: ?

getBundleId()

Gets the application bundle identifier.

Examples

let bundleId = DeviceInfo.getBundleId();
// "com.example.AwesomeApp"

isCameraPresent()

Tells if the device has any camera now.

Examples

DeviceInfo.isCameraPresent()
  .then((isCameraPresent) => {
    // true or false
  })
  .catch((cameraAccessException) => {
    // is thrown if a camera device could not be queried or opened by the CameraManager on Android
  });

Notes

  • Hot add/remove of camera is supported.
  • Returns the status of the physical presence of the camera. If camera present but your app don't have permissions to use it, isCameraPresent will still return the true

getCarrier()

Gets the carrier name (network operator).

Examples

DeviceInfo.getCarrier().then((carrier) => {
  // "SOFTBANK"
});

getCodename()

The current development codename, or the string "REL" if this is a release build.

Examples

DeviceInfo.getCodename().then((codename) => {
  // "REL"
});

getDevice()

The name of the industrial design.

Examples

DeviceInfo.getDevice().then((device) => {
  // "walleye"
});

getDeviceId()

Gets the device ID.

Examples

let deviceId = DeviceInfo.getDeviceId();
// iOS: "iPhone7,2"
// Android: "goldfish"
// Windows: "Y3R94UC#AC4"

getDisplay()

A build ID string meant for displaying to the user.

Examples

DeviceInfo.getDisplay().then((display) => {
  // "OPM2.171026.006.G1"
});

getDeviceName()

Gets the device name.

Examples

DeviceInfo.getDeviceName().then((deviceName) => {
  // iOS: "Becca's iPhone 6"
  // Android: ?
  // Windows: ?
});

This used to require the android.permission.BLUETOOTH but the new implementation in v3 does not need it. You may remove that from your AndroidManifest.xml if you had it for this API. iOS 16 and greater require entitlements to access user-defined device name, otherwise a generic value is returned (ie. 'iPad', 'iPhone')


getDeviceToken()

Gets the device token (see DeviceCheck). Only available for iOS 11.0+ on real devices. This will reject the promise when getDeviceToken is not supported, be careful with exception handling.

Examples

DeviceInfo.getDeviceToken().then((deviceToken) => {
  // iOS: "a2Jqsd0kanz..."
});

getFirstInstallTime()

Gets the time at which the app was first installed, in milliseconds.

Examples

DeviceInfo.getFirstInstallTime().then((firstInstallTime) => {
  // Android: 1517681764528
});

getFingerprint()

A string that uniquely identifies this build.

Examples

DeviceInfo.getFingerprint().then((fingerprint) => {
  // "google/walleye/walleye:8.1.0/OPM2.171026.006.G1/4820017:user/release-keys"
});

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

DeviceInfo.getFontScale().then((fontScale) => {
  // 1.2
});

getFreeDiskStorage()

Method that gets available storage size, in bytes, taking into account both root and data file systems calculation.

On iOS, this method accepts the following optional arguments:

  • 'total': Uses volumeAvailableCapacityKey
  • 'important': Uses volumeAvailableCapacityForImportantUsageKey
  • 'opportunistic': Uses volumeAvailableCapacityForOpportunisticUsageKey

For more details, refer to Apple Documentation on Checking Volume Storage Capacity.

Examples

DeviceInfo.getFreeDiskStorage().then((freeDiskStorage) => {
  // Android: 17179869184
  // iOS: 17179869184
});

DeviceInfo.getFreeDiskStorage('important').then((freeDiskStorage) => {
  // iOS: 18198219342 (important storage)
});

Notes

The API used by this method for Android was changed in v6.0.0. The older version has been maintained below as getFreeDiskStorageOld(). On iOS, getFreeDiskStorage() and getFreeDiskStorageOld() return the same value.


getFreeDiskStorageOld()

Old implementation of method that gets available storage size, in bytes.

Examples

DeviceInfo.getFreeDiskStorageOld().then((freeDiskStorage) => {
  // Android: 17179869184
  // iOS: 17179869184
});

Notes

From developer.android.com:

This method was deprecated in API level 29.

Return the primary shared/external storage directory.

Note: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.


getHardware()

The name of the hardware (from the kernel command line or /proc).

Examples

DeviceInfo.getHardware().then(hardware => {
  // "walleye"
});

getHost()

Hostname

Examples

DeviceInfo.getHost().then((host) => {
  // "wprd10.hot.corp.google.com"
});

getIpAddress()

Deprecated Gets the device current IP address. (of wifi only) Switch to react-native-netinfo/netinfo or react-native-network-info

Examples

DeviceInfo.getIpAddress().then((ip) => {
  // "92.168.32.44"
});

Android Permissions

Notes

Support for iOS was added in 0.22.0


getIncremental()

The internal value used by the underlying source control to represent this build.

Examples

DeviceInfo.getIncremental().then((incremental) => {
  // "4820017"
});

getInstallerPackageName()

The internal value used by the underlying source control to represent this build.

Examples

DeviceInfo.getInstallerPackageName().then((installerPackageName) => {
  // Play Store: "com.android.vending"
  // Amazon: "com.amazon.venezia"
  // Samsung App Store: "com.sec.android.app.samsungapps"
  // iOS: "AppStore", "TestFlight", "Other"
});

getInstallReferrer()

Gets the referrer string upon application installation.

Examples

DeviceInfo.getInstallReferrer().then((installReferrer) => {
  // If the app was installed from https://play.google.com/store/apps/details?id=com.myapp&referrer=my_install_referrer
  // the result will be "my_install_referrer"
});

getInstanceId()

Gets the application instance ID.

This attempts to get an instance ID from these sources, in this order:

  • a value under key instanceId in SharedPreferences file react-native-device-info
  • Firebase IID (if firebaseBomVersion or firebaseIidVersion is defined in gradle ext - deprecated)
  • GMS IID (if googlePlayServicesIidVersion or googlePlayServicesVersion is defined in gradle ext - deprecated)
  • a random UUID generated from java.util.UUID.randomUUID() and stored in SharedPreferences

If you are using the deprecated sources, the instance ID generated is stored in shared preferences so it will be stable during this major version of react-native-device-info.

In a future version of react-native-device-info, the Firebase IID and GMS IID implementations will be removed, and all future values will be the value (if any) stored in SharedPreferences, or a new random UUID that will then be stored and used for that app installation in the future.

Examples

DeviceInfo.getInstanceId().then((instanceId) => {
  // Android: da4e0245-5d6c-402a-a07c-0c5349f229e2
});

Notes

See https://developers.google.com/instance-id/


getLastUpdateTime()

Gets the time at which the app was last updated, in milliseconds.

Examples

DeviceInfo.getLastUpdateTime().then((lastUpdateTime) => {
  // Android: 1517681764992
});

getMacAddress()

Gets the network adapter MAC address.

Examples

DeviceInfo.getMacAddress().then((mac) => {
  // "E5:12:D8:E5:69:97"
});

Android Permissions

Notes

iOS: This method always return "02:00:00:00:00:00" as retrieving the MAC address is disabled since iOS 7


getManufacturer()

Gets the device manufacturer.

Examples

DeviceInfo.getManufacturer().then((manufacturer) => {
  // iOS: "Apple"
  // Android: "Google"
  // Windows: ?
});

getMaxMemory()

Returns the maximum amount of memory that the VM will attempt to use, in bytes.

Examples

DeviceInfo.getMaxMemory().then((maxMemory) => {
  // 402653183
});

getModel()

Gets the device model.

iOS warning: The list with device names is maintained by the community and could lag new devices. It is recommended to use getDeviceId() since it's more reliable and always up-to-date with new iOS devices. We do accept pull requests that add new iOS devices to the list with device names.

Examples

let model = DeviceInfo.getModel();
// iOS: ?
// Android: ?
// Windows: ?

getPhoneNumber()

The getPhoneNumber() has been removed. This method uses deprecated Android APIs. You can use react-native-sim-cards-manager to get the phone number.


getPowerState()

Gets the power state of the device including the battery level, whether it is plugged in, and if the system is currently operating in low power mode. Displays a warning on iOS if battery monitoring not enabled, or if attempted on an emulator (where monitoring is not possible)

Examples

DeviceInfo.getPowerState().then((state) => {
  // {
  //   batteryLevel: 0.759999,
  //   batteryState: 'unplugged',
  //   lowPowerMode: false,
  // }
});

getProduct()

The name of the overall product.

Examples

DeviceInfo.getProduct().then((product) => {
  // "walleye"
});

getPreviewSdkInt()

The developer preview revision of a prerelease SDK.

Examples

DeviceInfo.getPreviewSdkInt().then((previewSdkInt) => {
  // 0
});

getReadableVersion()

Gets the application human readable version (same as getVersion() + '.' + getBuildNumber())

Examples

let readableVersion = DeviceInfo.getReadableVersion();
// iOS: 1.0.1.32
// Android: 1.0.1.234
// Windows: ?

getSerialNumber()

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.

Examples

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

Notes

capability smbios

If you want to use this method in windows, you have to add smbios capability in your aplication. Please following this documentation for add the capability in your manifest file.


getSecurityPatch()

The user-visible security patch level.

Examples

DeviceInfo.getSecurityPatch().then((securityPatch) => {
  // "2018-07-05"
});

getSystemName()

Gets the device OS name.

Examples

let systemName = DeviceInfo.getSystemName();
// iOS: "iOS" on newer iOS devices "iPhone OS" on older devices (including older iPad models), "iPadOS" for iPads using iPadOS 15.0 or higher.
// Android: "Android"
// Windows: ?

getStartupTime()

Gets the time at which the current app process was started, in milliseconds.

Examples

DeviceInfo.getStartupTime().then((startupTime) => {
  // Android: 1517681764528
  // iOS: 1517681764528
});

getSystemVersion()

Gets the device OS version.

Examples

let systemVersion = DeviceInfo.getSystemVersion();
// iOS: "11.0"
// Android: "7.1.1"
// Windows: ?

getBuildId()

Gets build number of the operating system.

Examples

DeviceInfo.getBuildId().then((buildId) => {
  // iOS: "12A269"
  // tvOS: not available
  // Android: "13D15"
  // Windows: not available
});

getTags()

Comma-separated tags describing the build.

Examples

DeviceInfo.getTags().then((tags) => {
  // "release-keys, unsigned, debug",
});

getType()

The type of build.

Examples

DeviceInfo.getType().then((type) => {
  // "user", "eng"
});

getTotalDiskCapacity()

Method that gets full disk storage size, in bytes, taking into account both root and data file systems calculation.

Examples

DeviceInfo.getTotalDiskCapacity().then((capacity) => {
  // Android: 17179869184
  // iOS: 17179869184
});

Notes

The API used by this method for Android was changed in v6.0.0. The older version has been maintained below as getTotalDiskCapacityOld(). On iOS, getTotalDiskCapacity() and getTotalDiskCapacityOld() return the same value.


getTotalDiskCapacityOld()

Old implementation of method that gets full disk storage size, in bytes.

Examples

DeviceInfo.getTotalDiskCapacityOld().then((capacity) => {
  // Android: 17179869184
  // iOS: 17179869184
});

getTotalMemory()

Gets the device total memory, in bytes.

Examples

DeviceInfo.getTotalMemory().then((totalMemory) => {
  // 1995018240
});

getUniqueId()

This identifier is considered sensitive information in some app stores (e.g. Huawei or Google Play) and may lead to your app being removed or rejected, if used without user consent or for unapproved purposes. Refer to store policies for more information (see notes below).

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.

Examples

DeviceInfo.getUniqueId().then((uniqueId) => {
// iOS: "FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9"
// Android: "dd96dec43fb81c97"
// Windows: "{2cf7cb3c-da7a-d508-0d7f-696bb51185b4}"
});

Notes

  • iOS: This is IDFV or a random string if IDFV is unavaliable. Once UID is generated it is stored in iOS Keychain and NSUserDefaults. So it would stay the same even if you delete the app or reset IDFV. You can carefully consider it a persistent unique ID. It can be changed only in case someone manually override values in Keychain/NSUserDefaults or if Apple would change Keychain and NSUserDefaults implementations. Beware: The IDFV is calculated using your bundle identifier and thus will be different in app extensions.
  • android: Prior to Oreo, this id (ANDROID_ID) will always be the same once you set up your phone.
  • android: Google Play policy, see "persistent device identifiers". Huawei - AppGallery Review Guidelines see "permanent device identifier" and "obtaining user consent".

syncUniqueId()

This method is intended for iOS.

This synchronizes uniqueId with IDFV or sets new a random string.

On iOS it uses the DeviceUID uid identifier. On other platforms it just call getUniqueId() in this module.

Examples

DeviceInfo.syncUniqueId().then((uniqueId) => {
  // iOS: "FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9"
  // Android: "dd96dec43fb81c97"
  // Windows: ?
});

Notes

  • If user moved or restored data from one iOS device to second iOS device then he will have two different devices with same uniqueId in Keychain/NSUserDefaults. User can call syncUniqueId() on new iOS device. That will update his uniqueId from IDFV or a random string.

getUsedMemory()

Gets the app memory usage, in bytes.

⚠️ A note from the Android docs.

Note: this method is only intended for debugging or building a user-facing process management UI.

Examples

DeviceInfo.getUsedMemory().then((usedMemory) => {
  // 23452345
});

getSupportedMediaTypeList()

This method gets the list of supported media codecs.

Examples

DeviceInfo.getSupportedMediaTypeList().then((string[]) => {
  // ["audio/mpeg", "audio/mp4a-latm", "audio/mp4a-latm", "audio/mp4a-latm", "audio/mp4a-latm", "video/avc", "video/3gpp", "video/hevc", "video/mp4v-es", "video/av01", "video/avc", "video/avc", "video/avc", "video/avc"]
});

getUserAgent()

Gets the device User Agent.

Examples

DeviceInfo.getUserAgent().then((userAgent) => {
  // 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"
  // tvOS: not available
  // Android: "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_arm64 Build/SE1A.220630.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.114 Mobile Safari/537.36"
  // Windows: ?
});

getVersion()

Gets the application version. Take into account that a version string is device/OS formatted and can contain any additional data (such as build number etc.). If you want to be sure about version format, you can use a regular expression to get the desired portion of the returned version string.

Examples

let version = DeviceInfo.getVersion();
// iOS: "1.0"
// Android: "1.0" or "1.0.2-alpha.12"
// Windows: ?

isAirplaneMode()

Tells if the device is in Airplane Mode.

Examples

DeviceInfo.isAirplaneMode().then((airplaneModeOn) => {
  // false
});

Notes

  • This only works if the remote debugger is disabled.

isBatteryCharging()

Tells if the battery is currently charging.

Examples

DeviceInfo.isBatteryCharging().then((isCharging) => {
  // true or false
});

isEmulator()

Tells if the application is running in an emulator.

Examples

DeviceInfo.isEmulator().then((isEmulator) => {
  // false
});

isKeyboardConnected()

Tells if the device has a keyboard connected.

Examples

let isKeyboardConnected = DeviceInfo.isKeyboardConnected();
// true

isPinOrFingerprintSet()

Tells if a PIN number or a fingerprint was set for the device.

Examples

DeviceInfo.isPinOrFingerprintSet().then((isPinOrFingerprintSet) => {
  if (!isPinOrFingerprintSet) {
    // ...
  }
});

isTablet()

Tells if the device is a tablet.

Examples

let isTablet = DeviceInfo.isTablet();
// true

isLowRamDevice()

Tells if the device has low RAM.

Examples

let isLowRamDevice = DeviceInfo.isLowRamDevice();
// true

isDisplayZoomed()

Tells if the user changed Display Zoom to Zoomed

Examples

let isDisplayZoomed = DeviceInfo.isDisplayZoomed();
// true

isTabletMode()

Tells if the device is in tablet mode.

Examples

let isTabletMode = DeviceInfo.isTabletMode();
// true

isLandscape()

Tells if the device is currently in landscape mode.

Examples

DeviceInfo.isLandscape().then((isLandscape) => {
  // true
});

isMouseConnected()

Tells if the device has a mouse connected.

Examples

let isMouseConnected = DeviceInfo.isMouseConnected();
// true

hasGms()

Tells if the device supports Google Mobile Services.

Examples

DeviceInfo.hasGms().then((hasGms) => {
  // true
});

hasHms()

Tells if the device supports Huawei Mobile Services.

Examples

DeviceInfo.hasHms().then((hasHms) => {
  // true
});

hasNotch()

Tells if the device has a notch.

Examples

let hasNotch = DeviceInfo.hasNotch();
// true

hasDynamicIsland()

Tells if the device has a dynamic island.

Examples

let hasDynamicIsland = DeviceInfo.hasDynamicIsland();
// true

getDeviceType()

Returns the device's type as a string, which will be one of:

  • Handset
  • Tablet
  • Tv
  • Desktop
  • GamingConsole
  • Headset
  • unknown

Examples

let type = DeviceInfo.getDeviceType();
// 'Handset'

supported32BitAbis()

An ordered list of 32 bit ABIs supported by this device.

Examples

DeviceInfo.supported32BitAbis().then((abis) => {
  // ["armeabi-v7a", "armeabi"]
});

supported64BitAbis()

An ordered list of 64 bit ABIs supported by this device.

Examples

DeviceInfo.supported64BitAbis().then((abis) => {
  // ["arm64-v8a"]
});

supportedAbis()

Returns a list of supported processor architecture version

Examples

DeviceInfo.supportedAbis().then((abis) => {
  // [ "arm64 v8", "Intel x86-64h Haswell", "arm64-v8a", "armeabi-v7a", "armeabi", "win_x86", "win_arm", "win_x64", "win_arm64", "win_x86onarm64" ]});

hasSystemFeature(feature)

Tells if the device has a specific system feature.

Examples

DeviceInfo.hasSystemFeature('amazon.hardware.fire_tv').then((hasFeature) => {
  // true or false
});

getSystemAvailableFeatures()

Returns a list of available system features on Android.

Examples

DeviceInfo.getSystemAvailableFeatures().then((features) => {
  // ["android.software.backup", "android.hardware.screen.landscape", "android.hardware.wifi", ...]
});

isLocationEnabled()

Tells if the device has location services turned off at the device-level (NOT related to app-specific permissions)

Examples

DeviceInfo.isLocationEnabled().then((enabled) => {
  // true or false
});

isHeadphonesConnected()

Tells if the device is connected to wired headset or bluetooth headphones

Examples

DeviceInfo.isHeadphonesConnected().then((enabled) => {
  // true or false
});

isWiredHeadphonesConnected()

Tells if the device is connected to wired headset

Examples

DeviceInfo.isWiredHeadphonesConnected().then((enabled) => {
  // true or false
});

isBluetoothHeadphonesConnected()

Tells if the device is connected to bluetooth headset

Examples

DeviceInfo.isBluetoothHeadphonesConnected().then((enabled) => {
  // true or false
});

getAvailableLocationProviders()

Returns an object of platform-specfic location providers/servcies, with boolean value whether or not they are currently available.

NOTE: This function requires access to the Location permission on Android

Android Example

DeviceInfo.getAvailableLocationProviders().then((providers) => {
  // {
  //   gps: true
  //   network: true
  //   passive: true
  // }
});

iOS Example

DeviceInfo.getAvailableLocationProviders().then((providers) => {
  // {
  //   headingAvailable: false
  //   isRangingAvailable: false
  //   locationServicesEnabled: true
  //   significantLocationChangeMonitoringAvailable: true
  // }
});

getBrightness()

Gets the current brightness level of the device's main screen. Currently iOS only. Returns a number between 0.0 and 1.0, inclusive.

Examples

DeviceInfo.getBrightness().then((brightness) => {
  // iOS: 0.6
});

Hooks & Events

Supported in Windows, iOS & Android (web support for battery/charging-related APIs).

useBatteryLevel or RNDeviceInfo_batteryLevelDidChange

Fired when the battery level changes; sent no more frequently than once per minute.

Examples

import { useBatteryLevel } from 'react-native-device-info';

const batteryLevel = useBatteryLevel(); // 0.759999

<Text>{batteryLevel}</Text>;
import { NativeEventEmitter, NativeModules } from 'react-native';
const deviceInfoEmitter = new NativeEventEmitter(NativeModules.RNDeviceInfo);

deviceInfoEmitter.addListener('RNDeviceInfo_batteryLevelDidChange', (level) => {
  // 0.759999
});

useBatteryLevelIsLow or RNDeviceInfo_batteryLevelIsLow

Fired when the battery level is considered low (multiple times untill charged)

Platform Percentage
iOS 20
Android 15
Web 20
Windows 20

Examples

import { useBatteryLevelIsLow } from 'react-native-device-info';

const batteryLevelIsLow = useBatteryLevelIsLow(); // 0.19

<Text>{batteryLevelIsLow}</Text>;
import { NativeEventEmitter, NativeModules } from 'react-native';
const deviceInfoEmitter = new NativeEventEmitter(NativeModules.RNDeviceInfo);

deviceInfoEmitter.addListener('RNDeviceInfo_batteryLevelIsLow', (level) => {
  // 0.19
});

usePowerState or RNDeviceInfo_powerStateDidChange

Fired when the battery state changes or device enters in the power saving mode, for example when the device enters charging mode or is unplugged.

Examples

import { usePowerState } from 'react-native-device-info';

const powerState = usePowerState();
  // {
  //   batteryLevel: 0.759999,
  //   batteryState: 'unplugged',
  //   lowPowerMode: false,
  // }

<Text>{powerState}</Text>;
import { NativeEventEmitter, NativeModules } from 'react-native'
const deviceInfoEmitter = new NativeEventEmitter(NativeModules.RNDeviceInfo)

deviceInfoEmitter.addListener('RNDeviceInfo_powerStateDidChange', { powerState } => {
  // {
  //   batteryLevel: 0.759999,
  //   batteryState: 'unplugged',
  //   lowPowerMode: false,
  // }
});

useFirstInstallTime

Gets the time at which the app was first installed, in milliseconds.

Example

import { useFirstInstallTime } from 'react-native-device-info';

const { loading, result } = useFirstInstallTime(); // { loading: true, result: 1517681764528}

<Text>{loading ? 'loading...' : result}</Text>;

useDeviceName

Gets the device name.

Example

import { useDeviceName } from 'react-native-device-info';

const { loading, result } = useDeviceName(); // { loading: true, result: "Becca's iPhone 6"}

<Text>{loading ? 'loading...' : result}</Text>;

useHasSystemFeature

Tells if the device has a specific system feature.

Example

import { useHasSystemFeature } from 'react-native-device-info';

const { loading, result } = useHasSystemFeature('amazon.hardware.fire_tv'); // { loading: true, result: false }

<Text>{loading ? 'loading...' : result}</Text>;

useIsEmulator

Get whether the application is running in an emulator.

Example

import { useIsEmulator } from 'react-native-device-info';

const { loading, result } = useIsEmulator(); // { loading: true, result: false }

<Text>{loading ? 'loading...' : result}</Text>;

useManufacturer

Gets the device manufacturer.

Example

import { useManufacturer } from 'react-native-device-info';

const { loading, result } = useManufacturer(); // { loading: true, result: "Apple"}

<Text>{loading ? 'loading...' : result}</Text>;

useIsHeadphonesConnected

Tells if the device is connected to wired headset or bluetooth headphones.

This hook subscribes to the event, RNDeviceInfo_headphoneConnectionDidChange , and updates the result field accordingly.

Example

import { useIsHeadphonesConnected } from 'react-native-device-info';

const { loading, result } = useIsHeadphonesConnected(); // { loading: true, result: false}

<Text>{loading ? 'loading...' : result}</Text>;

useIsWiredHeadphonesConnected

Tells if the device is connected to wired headset.

This hook subscribes to the event, RNDeviceInfo_headphoneWiredConnectionDidChange , and updates the result field accordingly.

Example

import { useIsWiredHeadphonesConnected } from 'react-native-device-info';

const { loading, result } = useIsWiredHeadphonesConnected(); // { loading: true, result: false}

<Text>{loading ? 'loading...' : result}</Text>;

useIsBluetoothHeadphonesConnected

Tells if the device is connected to bluetooth headphones.

This hook subscribes to the event, RNDeviceInfo_headphoneBluetoothConnectionDidChange , and updates the result field accordingly.

Example

import { useIsBluetoothHeadphonesConnected } from 'react-native-device-info';

const { loading, result } = useIsBluetoothHeadphonesConnected(); // { loading: true, result: false}

<Text>{loading ? 'loading...' : result}</Text>;

useBrightness

Gets the current brightness level of the device's main screen. Currently iOS only. Returns a number between 0.0 and 1.0, inclusive.

This hook subscribes to the event, RNDeviceInfo_brightnessDidChange , and updates the brightness field accordingly.

Example

import { useBrightness } from 'react-native-device-info';

const brightness = useBrightness(); // 0.46578987897654567

<Text>{brightness}</Text>;
import { NativeEventEmitter, NativeModules } from 'react-native';

const deviceInfoEmitter = new NativeEventEmitter(NativeModules.RNDeviceInfo);

deviceInfoEmitter.addListener('RNDeviceInfo_brightnessDidChange', (brightness) => {
  // 0.46578987897654567
});

=======

Native interoperatibily

If you need to check for device type from the native side, you can use the following:

import com.learnium.resolver.DeviceTypeResolver

...
deviceTypeResolver = new DeviceTypeResolver(context);
...
//Check if the device is a Tablet:
if(deviceTypeResolver.isTablet){
  ...
}else{
  ...
}

Troubleshooting

When installing or using react-native-device-info, you may encounter the following problems:

<summary>[android] - Unable to merge dex / Multiple dex files / Problems with `com.google.android.gms`</summary>

react-native-device-info uses com.google.android.gms:play-services-gcm to provide getInstanceId(). This can lead to conflicts when building the Android application.

If you're using a different version of com.google.android.gms:play-services-gcm in your app, you can define the googlePlayServicesVersion gradle variable in your build.gradle file to tell react-native-device-info what version it should require. See the example project included here for a sample.

If you're using a different library that conflicts with com.google.android.gms:play-services-gcm, and you are certain you know what you are doing such that you will avoid version conflicts, you can simply ignore this dependency in your gradle file:

 compile(project(':react-native-device-info')) {
    exclude group: 'com.google.android.gms'
}
<summary>[ios] - ld: library not found for -lRNDeviceInfo-tvOS</summary>

Seems to be a bug caused by react-native link. You can manually delete libRNDeviceInfo-tvOS.a in Xcode -> [Your iOS build target] -> Build Phrases -> Link Binary with Libraries.

<summary>[ios] - [NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 “The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.”</summary>

This is a system level log that may be turned off by executing: xcrun simctl spawn booted log config --mode "level:off" --subsystem com.apple.CoreTelephony. To undo the command, you can execute: xcrun simctl spawn booted log config --mode "level:info" --subsystem com.apple.CoreTelephony

<summary>[ios] - Multiple versions of React when using CocoaPods "tries to require 'react-native' but there are several files providing this module"</summary>

RN<=59 You may need to adjust your Podfile like this if you use Cocoapods and have undefined symbols or duplicate React definitions

target 'yourTargetName' do
  # See http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge', # Include this for RN >= 0.47
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket', # Needed for debugging
    'RCTAnimation', # Needed for FlatList and animations running on native UI thread
    # Add any other subspecs you want to use in your project
  ]

  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  # Third party deps podspec link - you may have multiple pods here, just an example
  pod 'RNDeviceInfo', path: '../node_modules/react-native-device-info'

end

# if you see errors about React duplicate definitions, this fixes it. The same works for yoga.
post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end
<summary>[tests] - Cannot run my test suite when using this library</summary>

react-native-device-info contains native code, and needs to be mocked. Jest Snapshot support may work though.

If you do not have a Jest Setup file configured, you should add the following to your Jest settings and create the jest.setup.js file in project root:

setupFiles: ['<rootDir>/jest.setup.js'];

You should then add the following to your Jest setup file to mock the DeviceInfo Native Module:

import mockRNDeviceInfo from 'react-native-device-info/jest/react-native-device-info-mock';

jest.mock('react-native-device-info', () => mockRNDeviceInfo);

Checkout the example project for more information.

<summary>[warnings] - I get too many warnings (battery state, etc)</summary>

Some of the APIs (like getBatteryState) will throw warnings in certain conditions like on tvOS or the iOS emulator. This won't be visible in production but even in development it may be irritating. It is useful to have the warnings because these devices return no state, and that can be surprising, leading to github support issues. The warnings is intended to educate you as a developer. If the warnings are troublesome you may try this in your code to suppress them:

import { LogBox } from 'react-native';
LogBox.ignoreLogs(['Battery state']);

Release Notes

See the CHANGELOG.md.

Contributing

Please see the contributing guide.

react-native-dom

As a courtesy to developers, this library was made compatible in v0.21.6 with react-native-dom and react-native-web by providing an empty polyfill in order to avoid breaking builds.

Only getUserAgent() will return a correct value. All other API methods will return an "empty" value of its documented return type: 0 for numbers, '' for strings, false for booleans.

changelog

14.0.4 (2025-02-03)

Bug Fixes

  • android: quiet a build warning for users (07017cb)

14.0.3 (2025-02-03)

Bug Fixes

  • android: restore compatibility for Android <= 23 (75ea74e)

14.0.2 (2024-12-17)

Bug Fixes

14.0.1 (2024-11-23)

Bug Fixes

  • windows: Update RNDeviceInfoCPP.h for windows on ARM CPU arch on windows (#1679) (b2c7c4f)

14.0.0 (2024-10-26)

  • fix(android)!: remove AD_ID permission by removing auto-addition of play-services-iid (#1673) (5009115), closes #1673

BREAKING CHANGES

  • removed default fallback getInstanceId via play-services-iid dependency

This dependency has the unfortunate side effect of including AD_ID permission, which is not permissible for many types of applications.

If you relied on this functionality, you will need to define googlePlayServicesIidVersion in your android gradle build files ext version block. We previously used version 17.0.0 but there may be newer versions you could use if they work for

13.2.0 (2024-10-25)

Features

13.1.0 (2024-10-11)

Features

  • ios: implement all free disk storage types for ios 11+ (#1664) (99dc37c)

13.0.0 (2024-09-12)

  • fix(android)!: powerStateDidChange event returns powerState object not batteryState (#1655) (2d91018), closes #1655

BREAKING CHANGES

  • android powerStateDidChange now matches iOS with full powerState object not batteryState

The batteryState object is inside the powerState object, so if this is important to you, the change on android is now to go one-level deeper to get the batteryState

12.1.0 (2024-09-12)

Bug Fixes

  • ios: isDisplayZoomed on iPhone 12/13 mini (12fd354), closes #1581 #1581
  • RNInstallReferrerClient to use background threads for network operations to prevent ANR (2afb771)

Features

  • ios: add iPhone 16 device names / add missing iPad device names (#1657) (1c85272)

12.0.1 (2024-09-12)

Bug Fixes

  • android: add invalidate, use it from onCatalystInstanceDestroy (610714b)

12.0.0 (2024-09-12)

Bug Fixes

  • ios: Make unique id, unique per device and not per ios account(keychain) (#1642) (8198f22)

BREAKING CHANGES

  • ios: iOS getUniqueId is now per-device similar to android, not per-user

If you relied on the previous per-user behavior on iOS the recommended path forward is to use https://github.com/oblador/react-native-keychain with WHEN_UNLOCKED https://github.com/oblador/react-native-keychain?tab=readme-ov-file#keychainaccessible-enum and store your id as a key/value pair of your key and the id mapped into the username/password API of react-native-keychain

Co-authored-by: Humaid Arif Khan humaid@Humaidk-MBP.lan

11.1.0 (2024-05-15)

Features

  • android: detect MEmu emulator in isEmulator (ac172f6)

11.0.0 (2024-05-15)

  • fix(android)!: removed getPhoneNumber - use react-native-sim-cards-manager (#1617) (dce8bd5), closes #1617
  • feat(android)!: targetSdk 34 receiver export specification, requires compileSdk 33+ (#1621) (b32cde7), closes #1621

BREAKING CHANGES

  • removed getPhoneNumber to avoid Google Play Store rejections, use react-native-sim-cards-manager for similar functionality as desired
  • requires compileSdk 33+

10.14.0 (2024-05-15)

Features

  • Add isWiredHeadphonesConnected and IsBluetoothHeadphonesConnected (#1623) (fe66322)

10.13.2 (2024-04-21)

Bug Fixes

10.13.1 (2024-02-26)

Bug Fixes

  • ios: fix missing visionOS symbol compile error in xcode < 15 (#1615) (fd30902)

10.13.0 (2024-02-23)

Features

10.12.1 (2024-02-23)

Bug Fixes

  • wrap return value of useOnEvent in useMemo (2cdc43d)

10.12.0 (2023-11-28)

Features

  • android: implemented getSupportedMediaTypeList method (#1590) (89a3c4c)

10.11.0 (2023-09-19)

Features

  • android: add new isLowRamDevice constant (#1571) (f608fd5)

10.10.0 (2023-09-19)

Features

  • Add device names for iPhone 15 family, add check for dynamic island (#1569) (8e512ec)

10.9.0 (2023-08-28)

Features

  • windows: Implemented getHostNames() for windows (#1565) (eab4992)

10.8.0 (2023-07-12)

Features

  • windows: Implemented gethost() for windows (#1552) (aa4f6e0)

10.7.0 (2023-06-30)

Features

  • android: add support for React Native 0.73 (#1546) (38f9665)

10.6.1 (2023-06-29)

Bug Fixes

  • windows: bump WindowsTargetPlatformMinVersion (#1537) (7f0f1c2)

10.6.0 (2023-04-06)

Features

  • windows: implementation for useBatteryLevel & useBatteryLevelIsLow (18e3a54)

10.5.1 (2023-03-29)

Bug Fixes

10.5.0 (2023-03-28)

Features

  • windows: implementation of EnergySaverStatusChanged to emitt event RNDeviceInfo_powerStateDidChange (c974b31)

10.4.0 (2023-02-15)

Features

10.3.1 (2023-02-15)

Bug Fixes

  • ios: getUserAgentSync: separate memoKeys for sync / non-sync usage (#1506) (4bda3ba)

10.3.0 (2022-10-21)

Features

  • android, instanceId: implement instanceId as UUIDv4 in prefs (00aa218)

10.2.1 (2022-10-05)

Bug Fixes

  • android: getDeviceName handle new exception beginning API>=32 (#1471) (2364514)

10.2.0 (2022-09-18)

Features

  • ios, firstInstallTime: implement first install time for iOS (63b9feb)

10.1.2 (2022-09-13)

Bug Fixes

  • hasNotch: add iPhone 14 Pro / Pro Max to devices with notch (b818d9f)

10.1.1 (2022-09-09)

Bug Fixes

  • add getDeviceType and getDeviceTypeSync mocks (#1437) (d92e9f9)

10.1.0 (2022-09-09)

Bug Fixes

  • hasNotch: add iPhone 14 / iPhone 14 Plus to devices with notch (fc3b488)

Features

  • add device names for iPhone 14 family (2df220f)
  • add method to check if device has dynamic island (6119011)

10.0.2 (2022-07-18)

Bug Fixes

  • types, flow: add missing getUniqueIdSync in index.js.flow (#1441) (1d3890a)

10.0.1 (2022-07-11)

Bug Fixes

  • types: add missing hasGms hasHms flow types (#1436) (f51fb98)

10.0.0 (2022-07-08)

  • fix!: remove uniqueId from constants, move to sync/async methods (#1433) (449e1a8), closes #1433

BREAKING CHANGES

  • uniqueId constant is no longer available, use either getUniqueIdSync() or getUniqueId() (which now returns Promise<string>) instead. This is to confirm with app store policies that may reject your app if you access this constant before obtaining consent (thus requiring removal from the set of constants, which are fetched on startup)

9.0.2 (2022-06-04)

Bug Fixes

  • example, windows: Define an explicit 10.0 in example project to use latest windows 10 sdk (#1424) (92c4db6), closes #1288

9.0.1 (2022-06-04)

Bug Fixes

9.0.0 (2022-06-02)

  • fix(windows)!: Misc cleanup to windows. Support only RNW63 and newer. (#1419) (3bd6f88), closes #1419

BREAKING CHANGES

  • needs react-native-windows 0.63+ and MSVC build tools v142+ (Visual Studio 2019+), drop arm32

8.7.1 (2022-04-30)

Bug Fixes

  • windows: addListener/removeListeners native stubs to quiet warnings (#1408) (55166b4), closes #1288

8.7.0 (2022-03-29)

Features

8.6.0 (2022-03-28)

Features

8.5.1 (2022-03-21)

Bug Fixes

  • ios: add device name for iPhone SE 3rd gen (#1394) (8923995)

8.5.0 (2022-03-04)

Features

  • windows, supportedAbis: Add supportedAbis for windows (#1389) (8a97c4c)

8.4.9 (2022-02-07)

Bug Fixes

  • has-notch: add huawei p40 lite to notches list (#1378) (bbca38f)

8.4.8 (2021-11-17)

Bug Fixes

  • useBatteryIsLow: return battery level only if low on first run (#1347) (6b6fb5e)

8.4.7 (2021-11-13)

Bug Fixes

  • android, serial: Fix permission access to serial number (#1344) (ebc2e10)

8.4.6 (2021-11-12)

Bug Fixes

  • android: gracefully handle SecurityException in getPhoneNumber (3745097)

8.4.5 (2021-11-04)

Bug Fixes

  • hasNotch: added Huawei Honor Play and Samsung Galaxy A71 to hasNotch list (#1303) (f158ecc)

8.4.4 (2021-11-01)

Bug Fixes

  • internal/nativeinferface: fixing exception message when RNDeviceInfo is not found (068a433)
  • rndeviceinfo.podspec: changing podspec git source (e91d3fd)

Reverts

  • ios/rndeviceinfo: removing ios listener stubs (e157189), closes #1301

8.4.3 (2021-10-26)

Bug Fixes

  • getDeviceName: un-memoize device name so it updates (#1332) (7026844), closes #1272

8.4.2 (2021-10-25)

Bug Fixes

  • ios, deadlock: split battery level from power state fetch (30e7ebc), closes #1330

8.4.1 (2021-10-14)

Bug Fixes

  • ios, uniqueID: handle keychain duplicateItem during setValue (#1329) (a5ae298)

8.4.0 (2021-10-03)

Features

  • windows: add isTabletMode/isKeyboardConnected/isMouseConnected/DeviceType:GamingConsole (#1238) (e186394)

8.3.3 (2021-09-16)

Bug Fixes

8.3.2 (2021-09-15)

Bug Fixes

  • hasNotch: Add iPhone 13 lineup to list of devices with notch (#1307) (44193d5)

8.3.1 (2021-08-20)

Bug Fixes

  • addListener/removeListeners native stubs for react-native 0.65 copmatibility (3917f33), closes #1288

8.3.0 (2021-08-13)

Features

  • windows, device-id: Added get device id for windows (#1286) (dce34b7)

8.2.0 (2021-08-12)

Features

8.1.7 (2021-08-05)

Bug Fixes

  • windows: react-native-device-info don't work with apps in RNW v0.64 (#1279) (d1a5c4e)

8.1.6 (2021-08-05)

Bug Fixes

  • hasNotch: add Redmi Note 8 Pro to hasNotch list (#1276) (06e2b6c)

8.1.5 (2021-07-30)

Bug Fixes

  • iOS: Adds iPad Air 4th gen name description (#1273) (3c0d766)

8.1.4 (2021-07-21)

Bug Fixes

  • Updated getUsedMemory to pull from ActivityManager debug memory info (ed99cd3)

8.1.3 (2021-05-05)

Bug Fixes

  • web: only call navigator methods if navigator is defined (#1225) (35ffa26)

8.1.2 (2021-04-18)

Bug Fixes

  • notch: remove pixel 3a from devicesWithNotch.ts (#1221) (ee959d9)

8.1.1 (2021-04-18)

Bug Fixes

  • android: use mavenCentral vs jcenter before jcenter shutdown (#1220) (bffcce2)

8.1.0 (2021-04-12)

Features

  • ios: add getInstallerPackageName support for iOS (#1217) (9a844bf)

8.0.8 (2021-03-31)

Bug Fixes

  • ios: update getIpAddress to support IPv6-only interfaces (#1190) (c977f30)

8.0.7 (2021-03-24)

Bug Fixes

CHANGELOG

8.0.6

  • fix(ios, deviceType): support iOS-compiled app running on macOS (#1181, thanks @user-none!)
  • fix(ios, isEmulator): correct emulator detection for arm64 simulator (#1180, thanks @Arkkeeper!)

8.0.5

  • fix: remove husky from postinstall entirely

Apparently there is no way to conditionally run postinstall, and while we really want husky for contributors here, we must not fail on install of library consumers (and we don't want to install husky for everyone, even though it's a great package)

8.0.4

  • fix: prefix husky install with with npm or package install fails

Husky is just a pre-commit hook package we use for QA, quite unfortunate that as we ported to the next major version in v8.0.3 I broke the install for everyone. Apologies! @mikehardy

8.0.3

  • fix(types, PowerState): use Partial<PowerState> vs union with '{}' (#1175, thanks @vvscode!)

8.0.2

  • fix(hasNotch): fix missing Pixel 4a model name in devicesWithNotch.ts (@zarvedan)

8.0.1

  • BREAKING: Fix the exporting and importing of typings in ES6 build module (#1164, thanks @diego-antonelli!)

Note, if you use typescript, this requires a minimum version of typescript 3.8 This change was inadvertently released without realizing it was a breaking change, apologies. It is close enough to the 8.0.0 release that it will stand here though, without bumping to 9.0.0

8.0.0

  • BREAKING(ios, xcode): Xcode 12 required with #1137. Use 7.3.2 if you must use outdated Xcode (#1151)
  • feat(android, hms/gms): add ability to run without play services (#1156, thanks @saghul!)

7.4.0 was inadvertently breaking. I hadn't realized any iOS developers failed to update Xcode to stable after an Xcode release. For a variety of reasons, you should always keep Xcode up to date, nevertheless dropping Xcode 11 support is breaking. Update your Xcode or use 7.3.2.

7.4.0

  • feat(android, install referrer): add ability to run without install referrer (#1153, thanks @saghul!)
  • BREAKING feat(ios, catalyst): added DeviceTypeDesktop to getDeviceType() (#1137, thanks @exotexot!)
  • fix(android, install referrer): remove old install referrer api (#1150 @nicoburns!)
  • chore(ci, example): add ios/android CI, lint CI, de-lint project (@mikehardy)

7.3.2

  • fix: remove deprecated way of retrieving INSTALL_REFERRER on Android (#965) (@Minishlink)

7.3.1

  • fix(android, test): drop mockito to 3.6.28 to fix android test build break (thanks @jamsch!)

7.3.0

  • feat(android, build): add ability to specify firebase bill of materials for iid versioning (#1133, thanks @Dimon70007!)
  • fix(notch): add Redmi 9 to hasNotch list (#1140, thanks @esgudnason!)
  • test: Adding more tests and refactoring some getters (#1136, thanks @schie!)
  • chore: dependency updates (@mikehardy)

7.2.1

  • fix(test, mocks): extra comma syntax error in mock definition (#1134, thanks @DorianGrey!)

7.2.0

  • feat(windows): implement additional methods (#1122, thanks @jaimecbernardo!)
  • feat(windows): port C# Windows implementation to C++ (#1113, thanks @jaimecbernardo!)
  • feat(test, mocks): adding rest of jest mocks (#1132, thanks @schie!)
  • fix(ios, keychain): change keychain access control to non-deprecated value (#1131, thanks @dmitry-bluescape!)

7.1.0

  • feat(hasHms): added hasHms to indicate if Android device supports Huawei Mobile Services. (#1129, thanks @craig95!)
  • feat(hasGms): added hasGms to indicate if Android device supports Google Mobile Services. (#1129, thanks @craig95!)

This release includes a truly enormous amount of testing and internal refactoring work that has made the module much easier to maintain, all courtesy of @schie in the form of a pile of PRs implementing the same. Thank you, Dustin Schie!

7.0.2

  • fix(windows): remove use of Object.fromEntries (#1110, thanks @jaimecbernardo!)

7.0.1

  • fix(hasNotch): fix missing Redmi 7 and Pixel 3a model name in devicesWithNotch.ts (#1107, thanks @tronin!)
  • fix(hasNotch): fix missing Samsung A21s model in devicesWithNotch (#1106, thanks @djhr!)

7.0.0

  • BREAKING CHANGE: Increase iOS minimum to iOS 10. Stay on 6.x if you need to support iOS 9
  • fix(iOS): supporting getFontScale in App Extensions (#1097, thanks @schie!)
  • feat(mocks): add default set of mocks (#1102, thanks @schie!)

The change to iOS10 minimum was required to fix getFontScale for App Extensions react-native 0.63 already requires iOS 10 minimum, so this is in harmony with the ecosystem

6.2.0

  • feat(hooks): add useIsHeadphonesConnected hook (#1084, thanks again @schie!)

6.1.0

  • feat(hooks): add useManufacturer hook (#1083, thanks @schie!)
  • fix(types): add returnType to getPowerState (#1082, thanks @ferdicus!)

6.0.4

  • fix(android): fix swapped data/root values in getFreeDiskStorageSync (#1077, thanks @violetchow2611!)

6.0.3

  • fix: Xcode 12 compatibility (thanks @radko93! #1075)

6.0.2

  • fix(windows): Targetplatform change for cpp apps to use this module (#1072, thanks @tero-paananen!)

6.0.1

  • Added the 2nd generation iPhone SE to the deviceNamesByCode list (#1068, thanks @steve-lorenz!)

6.0.0

  • BREAKING CHANGE(android, storage): ReplacegetTotalDiskCapacity and getFreeDiskStorage implementations, original implementations are getTotalDiskCapacityOld and getFreeDiskStorageOld. New implementation adds Root and Data file systems. Old implementations are deprecated, they use deprecated Android APIs, and they will disappear in a future version. This should be a positive change as the resulting calculation should match Android settings storage calculation, but the old API is there if you need it, and you can open an issue to discuss if necessary. (#1054, thanks @gabriel-franzoni-pier!)

  • BREAKING CHANGE(windows, vNext): The windows support has been ported from C# (react-native-windows <= 0.59) to C++ (react-native-windows >= 0.59). This drops support for react-native-windows lower than 0.59. The port was developed and tested against react-native-windows 0.62.5. (1059#, thanks @tero-paananen!). The getTotalMemory APIs were dropped in the process (it appears react-native-windows vNext does not support them)

5.6.5

  • fix(hasNotch): add devices Blackview A30 (#1058, thanks @alexnaiman!)

5.6.4

  • fix(android): fix missing Huawei P30 model name in devicesWithNotch.ts (@tronin)

5.6.3

  • fix(ios): fix WkWebView crash from parallel getUserAgent calls (#1050, thanks @RojoHub!)

5.6.2

  • fix(types): import LocationProviderInfo type, export result types (#1041, thanks @mikehardy)
  • fix: power connection and power save events were not triggering correctly (#1042, thanks @mikehardy)
  • fix(ios): correctly calculate ios low battery threshold (#1039, thanks @mikehardy)

5.6.1

  • fix: react-native-web fix TypeError and battery (#1024) (thanks @jamesst20!)

I want to say I especially appreciate the help on the react-native-web implementation. Anyone that wants to help this library work better for react-native-web is more than welcome! I (@mikehardy, the currently active maintainer here) do not use react-native-web so I need all the help I can get. Cheers!

5.6.0

  • feat: Added syncUniqueId() for iOS devices (#922) (thanks @Bardiamist!)

5.5.8

  • fix: iOS check HFP in addition to A2DP in isHeadphonesConnected (thanks @CaptainJeff!)

5.5.7

  • fix: Android - build issues when building for electron (thanks @rcjmk10!)
  • chore: yarn upgrade --latest

5.5.6

  • fix: Android - safely handle PackageManager death in InstallReferrerClient (@mikehardy)
  • chore: upgrade gradle + gradle-plugin
  • chore: update all javascript dependencies
  • chore: refresh-example to react-native 0.62.2
  • chore: de-lint

5.5.5

  • fix: getModel on iOS now returns generic device type (e.g. "iPhone") if the specific model is unrecognized (@TheAlmightyBob)

5.5.4

  • fix: memoization of static boolean return values (@jmheik)
  • fix: add mac catalyst compatibility to getCarrier (#973) (thanks @robertying!)
  • fix: add wider exception handling in install referrer (thanks @jmunozDevsu!)

5.5.3

  • fix: add Redmi Note 9 to hasNotch list (#959) (thanks @euharrison!)

5.5.2

  • fix: avoid crash if missing InstallReferrer permission on Android (#955) (@mikehardy)

5.5.1

  • fix: RNDeviceInfo_powerStateDidChange event argument type error (@mikehardy)

5.5.0

  • feat: add getInstallerPackageName for android (#912) (thanks @codecog!)
  • fix: switch to InstallReferrer API (#947) (thanks @skantus!)

5.4.4

  • feat: add Huawei P Smart devices to notch list (#945) (thanks @sanborN!)

5.4.3

  • fix: only reject once from DeviceCheck APIs (fixes Simulator crash) (@mikehardy)

5.4.2

  • fix: remove yarn as a requirement (#943) (thanks @gie3d!)
  • chore: update dependencies (@mikehardy)

5.4.1

  • fix: Fix getDeviceToken crash on IOS simulator (#929) (thanks @Taym95!)

5.4.0

  • feat + fix: tabbed example, improved types, efficient Platform usage (thanks @zoontek!)
  • feat: Added getDeviceToken() using DeviceCheck API on iOS 11.0+ (thanks @AntoineDoubovetzky!)
  • fix: hasNotch correctly matches Xiaomi Mi 9 (thanks @BogdanTaranenko!)
  • docs: fix upgrade links in README TOC (thanks @Simek!)
  • docs: fix type in README useIsEmulator example (thanks @zusinShinpei!)

5.3.1

  • types: fix Flow types (thanks @grit96!)

5.3.0

  • feat: Added web support for isCameraPresent, isLocationEnabled, isAirplaneMode, getBaseOs, getFreeDiskStorage, getMaxMemory, getTotalDiskCapacity, getTotalMemory, getUsedMemory and battery/charging-related APIs. (thanks @robertherber!)

5.2.0

  • feat: isHeadphonesConnected() / isHeadphonesConnectedSync() (thanks @chakrihacker!)

5.1.0

This release allows you to use the firebase iid library for unique ids - it's the backwards-compatible but future direction of unique ids on Android, you should move to it by using firebaseIidVersion in your android/build.gradle file ext{} block to specify the library version

  • feat: android native interoperability - determine isTablet from android native (thanks @andresesfm!)
  • feat: android unique ID forward-ported to firebase, w/great backwards-compatibility (thanks @andresesfm and Andres Aguilar!)

5.0.1

  • re-package of 5.0.0 without change except delete accidental inclusion of example/android/app/build

5.0.0

  • BREAKING: (from 4.0.2-rc.1) getDeviceType is constant now - no need for getDeviceTypeSync This is a tiny breaking change, easy to adopt:
    1. getDeviceTypeSync --> getDeviceType
    2. getDeviceType.then(type => {}); --> let type = getDeviceType();
  • feat: Hooks! Add useBatteryLevel(), useBatteryLevelIsLow(), usePowerState methods (thanks @magrinj!)
  • fix: iOS use CFBundleName if CFBundleDisplayName null (Fixes #846, thanks @rizwankce!)
  • chore: add support for 2019 iPads models in 'model' mapping (thanks Edward Wong!)
  • chore: add support for motorola one vision in hasNotch (thanks @euharrison!)
  • docs(README): Fixed link in TOC (thanks @martinvol!)
  • docs(README): Fixed example code hasNotch() - constant, no Promise (thanks @cereme!)
  • docs(README): Fixed example code getDeviceId() - constant, no Promise (thanks @adambutler!)
  • docs(README): Fixed getReadableVersion() sub-API references (thanks @djorkaeffalexandre!)
  • chore: yarn upgrade --latest to update dependencies (@mikehardy)

4.0.2-rc.1

  • BREAKING: getDeviceType converted to a constant (minor breaking change, but will release as 5.0.0 just in case)

4.0.1

  • released from 4.0.1-rc.1 without change

4.0.1-rc.1

  • docs(README): link to v3->v4 migraiton guide
  • docs(CHANGELOG): entries for rest of 4.0.1-beta series

4.0.1-beta.8

  • fix: iOS getBundleId incorrectly returning buildId vs bundleId
  • fix: hasNotch correctly matches Nokia 6.1 Plus

4.0.1-beta.7

  • fix: iOS isTablet was always returning false
  • fix: hasSystemFeatureSync incorrectly returned Promise

4.0.1-beta.6

  • fix: hasSystemFeatureSync incorrectly returning a Promise on iOS @mikehardy
  • fix: isTablet on iOS always returning false @mikehardy

4.0.1-beta.5

  • fix: iOS getModel always returned generics @mikehardy

4.0.1-beta.4

  • BREAKING CHANGE: rename getCameraPresence to isCameraPresent to match other booleans (#810) @mikehardy

4.0.1-beta.3

4.0.1-beta.2

4.0.1-beta.1

  • BREAKING CHANGE: DeviceType: Renamed Unknown to unknown for consistency across the project (@johan-dutoit)
  • fix: typescript conversion mopup (@johan-dutoit)

4.0.0 (released / revoked on npm)

This was almost working but had some issues so was revoked on npmjs.com

3.1.4

  • fix: chain getReadableVersion APIs to JS vs native, protects web from native calls (Fixes #796)

3.1.3

  • chore: add support for 2019 iPhone models in 'hasNotch' mapping

3.1.2

The above PR also included a refresh/update of the iOS model list and improved getModel caching - a thorough job

3.1.1

3.1.0

3.0.0

  • release: promoted release from 3.0.0-rc.5 without change

3.0.0-rc.5

  • fix: various fixes similar to / prompted by #771 / #768 / #769
  • fix: getSystemName() returns value on ios+android #771 thanks @cmpayc!
  • fix: getUniqueId() only returned value 1st call #768 thanks @tamhv!
  • fix: getModel() not working on iOS #769 Thanks @rnnyrk!

3.0.0-rc.4

  • feat: memoize static return values for performance

3.0.0-rc.3

  • fix: TypeScript getPowerState() return type was Object instaed of PowerState interface
  • fix: TypeScript definition file was missing getPhoneNumberSync()

3.0.0-rc.2

  • Added a sync version of each API call, in practice it is very difficult to consume async APIs during app bootstrap and device info is frequently fundamental to app startup behavior. This still preserves the change away from paying the entire cost of information retrieval at startup - now you will only pay for exactly what you need.

3.0.0-rc.1

  • fix incorrect use of macos for API selection vs ios in rc.3, rendering ios builds mostly useless
  • verified last of the v2->v3 discrepancies, this is a release candidate now

3.0.0-beta.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)
  • feat: you no longer have to be careful with platform-specific APIs, all APIs will work, just returning standard "unknown" return values (see above breaking change, and example App.js usage)

3.0.0-beta.2

  • fix all emulator/simulator v2->v3 discrepancies

3.0.0-beta.1

Each BREAKING CHANGE contains the required information to migrate. The example App.js shows sample usage.

2.3.2

2.3.1

2.3.0

2.2.2

2.2.1

2.2.0

2.1.4

2.1.3

2.1.2

2.1.1

2.1.0

2.0.4

2.0.3

2.0.2

2.0.1

2.0.0

  • breaking: no functional change from 1.8.0, but isLocationEnabled requires minCompileSdk 28

1.8.0 (unpublished: unintended breaking change)

1.7.0

1.6.2

1.6.1

1.6.0

1.5.1

1.5.0

1.4.3

1.4.2

iOS notice

This is existing policy but is worth mentioning: The list with device names (returned by getModel()) is maintained by the community and could lag new devices. It is recommended to use getDeviceId() since it's more reliable and always up-to-date with new iOS devices. We do accept pull requests that add new iOS devices to the list with device names

1.4.1

  • fix: repair flow types from #436 - 'Object' vs 'object'

1.4.0

1.3.0

1.2.0

1.1.0

1.0.1

1.0.0

  • First major version, features (and bugs) copied from 0.29.1

0.29.1

On March 12 2019, this repository was moved from https://github.com/rebeccahughes/react-native-device-info to https://github.com/react-native-community/react-native-device-info

0.29.0

0.28.1

0.28.0

0.27.1

0.27.0

0.26.5

0.26.4

0.26.3

0.26.2

0.26.1

0.26.0

0.25.1

0.25.0

0.24.3

  • Support React Native Windows 0.57, minimal version is now 10.0.14393 for the target platform

0.24.2

0.24.1

0.24.0

0.23.0

0.22.6

0.22.5

0.22.4

0.22.3

0.22.2

0.22.1

0.22.0

0.21.5

  • Rolled back the Pod change made in 0.21.1

0.21.4

0.21.3

0.21.2

0.21.1

0.21.0

0.20.0

0.19.0

0.18.0

0.17.4

0.17.3

  • Fix production build crash on Android introduced in #313

0.17.2

0.17.1

  • Fix bad import for web polyfill

0.17.0

0.16.0

0.15.3

0.15.2

0.15.1

0.15.0

0.14.0

0.13.0

0.12.1

0.12.0

Diff

0.11.0

  • Add support for RN > 0.47
  • Update typescript definitions

Diff

0.10.2

  • Add typescript definitions

Diff

0.10.1

  • Add isPinOrFingerprintSet method
  • Add support for RN > 0.40

Diff

0.10.0

  • Semver fix

Diff

0.9.8

Diff

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

0.9.1

adds support for the iPhone SE and new iPad Pro

0.9.0

adds support for device country and changes the iOS device name to match Apple branding

0.8.4

don't use destructuring

0.8.3

removes the default bluetooth permission

0.8.2

change deployment target to iOS 8

0.8.1

removes unnecessary peerDependencies

0.8.0

tweaks how device locale works on Android. If it's available it will use the toLanguageTag that is more inline with iOS. (See #14)

0.7.0

adds two new parameters, Device Locale and User Agent.

0.5.0

adds a new parameter; Device Id. On iOS this is the hardware string for the current device (e.g. "iPhone7,2"). On Android we use the BOARD field which is the name of the underlying board, e.g. "goldfish". The way that the module gets the device model on iOS has also changed to be based on the Device Id; now instead of getting a generic product family e.g. "iPhone", it will return the specific model e.g. "iPhone 6".