Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mchinyakov/react-native-device-info
Device Information for React Native iOS and Android
https://github.com/mchinyakov/react-native-device-info
Last synced: 3 months ago
JSON representation
Device Information for React Native iOS and Android
- Host: GitHub
- URL: https://github.com/mchinyakov/react-native-device-info
- Owner: mchinyakov
- License: mit
- Fork: true (react-native-device-info/react-native-device-info)
- Created: 2015-10-07T10:43:26.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-07T12:07:13.000Z (about 9 years ago)
- Last Synced: 2024-08-05T02:03:00.482Z (3 months ago)
- Language: Java
- Homepage:
- Size: 104 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-react-native - react-native-device-info-pod ★3 - Get device information using react-native (Components / System)
- awesome-react-native - react-native-device-info-pod ★3 - Get device information using react-native (Components / System)
- awesome-react-native - react-native-device-info-pod ★3 - Get device information using react-native (Components / System)
- awesome-react-native-ui - react-native-device-info-pod ★1 - Get device information using react-native (Components / System)
- awesome-react-native - react-native-device-info-pod ★3 - Get device information using react-native (Components / System)
README
## react-native-device-info
Device Information for react-native
## Installation
First you need to install react-native-device-info:
```javascript
npm install react-native-device-info --save
```### Installation (iOS)
In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name] Go to node_modules ➜ react-native-device-info and add the .xcodeproj file
In XCode, in the project navigator, select your project. Add the lib*.a from the deviceinfo project to your project's Build Phases ➜ Link Binary With Libraries Click .xcodeproj file you added before in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React - mark both as recursive.
Run your project (Cmd+R)
(Thanks to @brysgo for writing the instructions)
### Installation (Android)
* In `android/setting.gradle`
```gradle
...
include ':RNDeviceInfo', ':app'
project(':RNDeviceInfo').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
```* In `android/app/build.gradle`
```gradle
...
dependencies {
...
compile project(':RNDeviceInfo')
}
```* register module (in MainActivity.java)
```java
import com.learnium.RNDeviceInfo.*; // <--- importpublic class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
......@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new RNDeviceInfo()) // <------ add here
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();mReactRootView.startReactApplication(mReactInstanceManager, "ExampleRN", null);
setContentView(mReactRootView);
}......
}
```(Thanks to @chirag04 for writing the instructions)
## Example
```js
var DeviceInfo = require('react-native-device-info');console.log("Device Unique ID", DeviceInfo.getUniqueID()); // e.g. FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9
console.log("Device Manufacturer", DeviceInfo.getManufacturer()); // e.g. Apple
console.log("Device Model", DeviceInfo.getModel()); // e.g. iPhone
console.log("Device Name", DeviceInfo.getSystemName()); // e.g. iPhone OS
console.log("Device Version", DeviceInfo.getSystemVersion()); // e.g. 9.0
console.log("Bundle Id", DeviceInfo.getBundleId()); // e.g. com.learnium.mobile
console.log("Build Number", DeviceInfo.getBuildNumber()); // e.g. 89
console.log("App Version", DeviceInfo.getVersion()); // e.g. 1.1.0
console.log("App Version (Readable)", DeviceInfo.getReadableVersion()); // e.g. 1.1.0.89
```