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 i
if using TypeScript, there is a type in react-native called PlatformIOSStatic
, you need to force-cast Platform
to PlatformIOSStatic
.
import { Platform, PlatformIOSStatic } from 'react-native'
if (Platform.OS === 'ios') {
const platformIOS = Platform as PlatformIOSStatic
console.log(platformIOS.isPad)
console.log(platformIOS.isTVOS)
}
The interface design here is pretty bad, hope RN team would improve it.