Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fixt/react-native-device-specs
Detects device type on both android and ios
https://github.com/fixt/react-native-device-specs
Last synced: 3 months ago
JSON representation
Detects device type on both android and ios
- Host: GitHub
- URL: https://github.com/fixt/react-native-device-specs
- Owner: fixt
- Created: 2015-09-30T20:58:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-22T18:54:09.000Z (over 8 years ago)
- Last Synced: 2024-11-04T05:02:35.903Z (3 months ago)
- Language: Java
- Size: 41 KB
- Stars: 11
- Watchers: 6
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-react-native - react-native-detect-device ★11 - Detect a device on iOS or android in react-native. (Components / System)
README
# React Native Device Specs
RNDeviceSpecs detects the specifications of the device it is running on. Requiring or importing the module will give you an object with properties that describe the user's device.
## Add it to your project
### Install
`npm install react-native-device-specs --save`
### iOS
Open your project in XCode, right click on `Libraries`, click `Add files to (Your Project Name)`, and select `RNDeviceSpecs.xcodeproj`Add `libRNDeviceSpecs.a` to `Build Phases` --> `Link Binary With Libraries`
### Android
In `android/settings.gradle`
below `include ':app'`
add:
```
...
include ':react-native-device-specs'
project(':react-native-device-specs').projectDir = new File(settingsDir, '../node_modules/react-native-device-specs')
```In `android/app/build.gradle`
```
dependencies {
...
compile project(':react-native-device-specs')
}
```In `android/app/src/main/java/com/YourProject/MainActivity.java`
add:
```
import com.joinpeach.react.device.specs.*; // <--- add thispublic 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 RNDeviceSpecsModule()) // <- and add this
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();mReactRootView.startReactApplication(mReactInstanceManager, "YourProject", null);
setContentView(mReactRootView);
}
}
```
### Use it!
Use `import specs from 'react-native-device-specs'` or `var specs = require('react-native-device-specs')` in your project!## Properties
- `platform`: The platform code.
- `storageSize`: The quoted storage size (GB) given by Apple (Ex: 32, 64, 128)
- `diskSpace`: The actual size of the disk.
- `carrier`: The carrier of device or `'No Carrier'` for Simulators or Devices without a carrier.## Contributing
Feel free to submit a pull request with feature suggestions or device updates. Please maintain a consistent syntax for new devices (See lib/iosModels.js for examples)