React Native:如何确定设备是 iPhone 还是 iPad

问题描述:

我知道使用 React Native 我们可以使用 Platform 模块确定正在运行的是 iOS 还是 Android,但是我们如何确定 iOS 上正在使用的是什么设备?

I know with React Native that we have the ability to determine whether iOS or Android is being run using the Platform module, but how can we determine what device is being used on iOS?

截至 2018 年 2 月 9 日还有

As of 9.02.2018 there is also

import { Platform } from 'react-native'
Platform.isPad // boolean

请注意(截至目前)它没有安卓版本.

Mind that (as of now) it has no android counterpart.

  • IOS https://github.com/facebook/react-native/blob/master/Libraries/Utilities/Platform.ios.js#L23
  • Android https://github.com/facebook/react-native/blob/master/Libraries/Utilities/Platform.android.js (no isPad!)