Code Monkey home page Code Monkey logo

react-native-device's Introduction

React Native Device [deprecated]

This project is no longer maintained. You can still use it as is, but bugs will no longer be fixed, features will no longer be implemented. An alternative to this package might be react-native-device-info

NPM Stats

A wrapper for the native iOS UIDevice & Android Build class allowing you to access device properties and screen dimensions. Currently only for React Native iOS, Android support in progress.

Installation (iOS)

First install the package to your project from NPM...

npm install react-native-device --save

Then within the package folder just add both the .h and .m classes to your project...

Methods

Device.isIpad()

The device model is of type iPad

Device.isIphone()

The device model is of type iPhone

Properties

Device.model

The device model, such as iPhone or iPad

Device.deviceName

The device name, such as John Smith's iPhone

Device.systemName

The device OS name, such as iPhone OS

Device.systemVersion

The device OS version, such as 8.4

Device.deviceVersion

The specific device version, such as iPhone 4S or iPhone 6 - All model options

Example

'use strict';

var Device = require('react-native-device');

var ExampleApp = React.createClass({
  render: function() {
    if (Device.isIpad()) {
      // return iPad layout
    } else {
      // return iPhone layout
    }
  }
});

react-native-device's People

Contributors

kkjdaniel avatar rwoverdijk avatar viix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-native-device's Issues

Update NPM Package & Description

Currently NPM doesn't reflect the NPM package, I've updated the package.json so should just be a case of pulling and publishing.

Also I think it may be a good idea to change the repo description to reflect the updated features, something along the lines of "A wrapper for the native UIDevice Class"?

Thanks,
Karl

Please release the latest code in Master

I'm using the latest code in master for my RN project, because all I need is DeviceUtil.deviceVersion and the latest DeviceUtil.m to get the device info string. Please deploy a build of what you have in master when you have the chance, because what you have in master is of critical importance to my RN project, and it works beautifully. For the time being, I'm setting my package.json for react-native-device to "https://github.com/GertjanReynaert/react-native-device" in order to use your wonderful library in my app, but of course I'd rather set this to a version.

[Suggestion] Using the UIDevice class

Ideally given the use case for detecting the device, you'd want to use UIDevice, right? Moving to it would be a pretty big shift for the entire repo, but will keep the library relevant when new devices come out. It also fits in with the name of the repo itself. What do you think?

Imagine exposing all of this in JS: GBDeviceInfo

Duplicate module provider

After having installed react-native-device with [email protected], the following error has been raised by flow

~/myapp/node_modules/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.js: ActionSheetIOS
Duplicate module provider
  ~/myapp/node_modules/react-native-device/node_modules/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.js: current provider

Same kind of error goes for all other providers. There seem to be some overlap with the libraries covered by flow.

I thought maybe you would have some clue about how to fix this?

React Native Android Support

Support for React Native Android, using the Android Build class.

String _OSVERSION = System.getProperty("os.version");
String _RELEASE = android.os.Build.VERSION.RELEASE;
String _DEVICE = android.os.Build.DEVICE; 
String _MODEL = android.os.Build.MODEL; 
String _PRODUCT = android.os.Build.PRODUCT; 
String _BRAND = android.os.Build.BRAND; 
String _DISPLAY = android.os.Build.DISPLAY; 
String _CPU_ABI = android.os.Build.CPU_ABI; 
String _CPU_ABI2 = android.os.Build.CPU_ABI2; 
String _UNKNOWN = android.os.Build.UNKNOWN; 
String _HARDWARE = android.os.Build.HARDWARE;
String _ID = android.os.Build.ID; 
String _MANUFACTURER = android.os.Build.MANUFACTURER; 
String _SERIAL = android.os.Build.SERIAL; 
String _USER = android.os.Build.USER; 
String _HOST = android.os.Build.HOST;

New tagline for repo : "A wrapper for the native UIDevice & Android Build class"

@GertjanReynaert

Add rnpm support

I like this library, but adding a cumbersome manual step to installation adds a high burden for getting reproducable builds and conistency among developers in my project.

Would it be possible to add support for rnpm (http://www.reactnative.com/react-native-package-manager/) , so that rnpm link does what's currently described in the screenshot in the README ?

Ability to Set Device Model for Unit Tests

This library is great! I've started using ternary expressions such as Device.isIpad() ? a : b throughout my code. But now I'm at a point where I'd like to test it (I am using Enzyme to unit test my entire app).

Therefore, it would be great if this library supplied a setDevice method that can be invoked before the tests run. Otherwise, as it currently stands, Device.model is evaluated as undefined in all tests, so these ternary expressions are untestable.

upgrade to v6

There seem to be a lot of issues I am facing whilst trying to upgrade to react-native 0.6.0-rc

Any help ? Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.