Use the PlatformConstants module to retrieve:
Ensure that you import NativeModules
before you use the PlatformConstants
module.
getOsVersion()
getPlatform()
android
for Android, ios
for iOS, tvos
for tvOS, osx
for macOS, uwp
for Xbox, ps4
for PS4, cloud
for Roku, and tizen
for tizen-nacl.
You can use this method to implement platform-specific code.getReactNativeVersion()
import { NativeModules } from 'react-native';
NativeModules.PlatformConstants.platform : null;
if (NativeModules.PlatformConstants.osVersion === {{ page.version }}) {
console.log('Running on {{ page.engine-name }} {{ page.version }}!');
}
if (NativeModules.PlatformConstants.platform === 'ios') {
// code itself, or maybe even a require('codeForIOS.js');
} else if (NativeModules.PlatformConstants.platform === 'android') {
// code itself, or maybe even a require('codeForAndroid.js');
}
console.log('Running on Facebook's React-Native ${NativeModules.PlatformConstants.reactNativeVersion}!');
No results yet. Please begin typing a keyword to search the You.i TV Developer Portal...
Try to search with a different keyword or remove search filters.