Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

react-native-device-info

> 前端框架
Open source

Device Information for React Native iOS and Android

6.7K stars0 likes2 views
WebsiteGitHub

About

Device Information for React Native iOS and Android

react-native-device-info

Device Information for React Native.

TOC

  • Installation
  • Linking
  • Usage
  • API
  • Hooks & Events
  • Troubleshooting
  • Release Notes
  • react-native-dom / react-native-web

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:

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

or using yarn:

bash
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

Android
…

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

javascript
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> ❌ ✅ ❌ ❌ ❌
getAppSetId() Promise<AppSetIdInfo> ❌ ✅ ❌ ❌ ❌
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 ✅ ✅ ✅

Issues· 23 open

View all issuesOpen on GitHub
  • #1773

    useIsHeadphonesConnected does not detect Bluetooth Changes on Android

    Updated Aug 30, 2026
  • #1797

    isEmulatorSync() crashes on Android 15/16 with compileSdk 36 — getEnabledInputMethodList() returns InputMethodInfoSafeList

    Updated Aug 26, 2026
  • #1762

    Web: TypeError when navigator.getBattery() resolves with null

    Updated Aug 1, 2026

> Tags

TypeScripthacktoberfestreact-native

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 23, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架