Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Detects device type on both android and ios

NotificationsYou must be signed in to change notification settings

fixt/react-native-device-specs

Repository files navigation

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 onLibraries, clickAdd files to (Your Project Name), and selectRNDeviceSpecs.xcodeproj

AddlibRNDeviceSpecs.a toBuild Phases -->Link Binary With Libraries

Android

Inandroid/settings.gradlebelowinclude ':app'add:

...include ':react-native-device-specs'project(':react-native-device-specs').projectDir = new File(settingsDir, '../node_modules/react-native-device-specs')

Inandroid/app/build.gradle

dependencies {    ...    compile project(':react-native-device-specs')}

Inandroid/app/src/main/java/com/YourProject/MainActivity.javaadd:

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!

Useimport specs from 'react-native-device-specs' orvar 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)

About

Detects device type on both android and ios

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp