The Easiest Way to Get React Native Device Information
Free article submittion
Fady Soliman

The most straightforward approach to retrieve the device information in a React Native App

Code Snippets Included


Building a great React Native app more likely requires retrieving the mobile device details like the operating system, version, bundle ID and much more. You probably would need these information to compare versions, or perhaps check if the current operating system is Android or iOS and so on.


React Native Device Info Demo Example


In this post, the easiest way to get the device information in React Native will be illustrated easily and step by step. React Native does not provide all the required device details out-of-the-box, that's why a plugin is needed to retrieve these information.


The plugin used is react-native-device-info.


Installing React-Native-Device-Info Plugin in your React Native project

To start off, add the React Native device info plugin in your app by running the following command.


yarn add react-native-device-info && cd ios && pod install && cd ..


The previous command will add react-native-device-info plugin to your app and also install the required Cocoa pods using the pod file in the iOS project directory. Starting with React Native version 0.60.5 (which is the latest version by the time of this writing), you are not required to link any libraries, linking is done automatically, but you have to install Cocoa pods.


To migrate your React Native to version 0.60.5, we recommend that you read this post.


Importing the plugin

The next step is to start using the plugin by importing it in your component. To do so, place the following import line of code among your import statements


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


Calling the React Native Device Info Plugin

To start reading the device info, you can call any of the following plugin APIs based on what you need to do in your app.

  1. DeviceInfo.getUniqueID() - to get the device unique ID. This ID will change if the app is uninstalled.
  2. DeviceInfo.getManufacturer() - to get the device manufacturer, for example: Apple.
  3. DeviceInfo.getModel() - to get the device model, for example iPhone X.
  4. DeviceInfo.getSystemVersion() - to get the system version, for example, 12.0 or 9.0.
  5. DeviceInfo.getBundleId() - to get the bundle ID, for example, com.myapp.ReactNativeDeviceInfo
  6. DeviceInfo.getBuildNumber() - to get the build number.
  7. DeviceInfo.getVersion() - to get the app version, for example, 1.0.0.
  8. DeviceInfo.getDeviceName() - to get the device name, for example, John's iPhone.
  9. DeviceInfo.getUserAgent() - to get the user agent, check the app screenshot above.
  10. DeviceInfo.getDeviceLocale() - to get the device locale, for example, en, to display some content that matches device language.
  11. DeviceInfo.getDeviceCountry() - to get the country, for example, US.


Note: Not all the APIs are compatible with iOS or Android. We recommend that you check the plugin documentation for more details about the platform incompatibilities.


The react-native-device-info provides more information than what was mentioned earlier, we recommend that you check this documentation for more information that you can retrieve in your app.


If you found any problems or issues, please feel free to share them in the comments and I will gladly provide help.

Related Posts

About The Author

Fady Soliman

An experienced, resourceful and highly motivated IT professional, with a proven record of success in both Stack Development and Software Architecture. Possesses a wealth of transferable skills, including outstanding interpersonal, problem solving and staff management abilities. A capable organizer, quick to grasp – and make good use of – new ideas and information, and reliable and conscientious in all he takes on.

Did you find this helpfull?

Leave your Comment

Sponsored Posts
Create a Sponsored Blog Post
Weekly Top List
Cheap SEO Backlink