Platform-Specific Code

Sometimes, given the limitations or extra capabilities of a particular target platform, you need to create platform-specific code. You.i Platform’s solution enables you to do the same things you can do with Facebook React Native, but in a different way. We manage all supported target platforms for you, under a single React Native platform called youi.

Normally, to find an app’s target platform with RN, you’d call the RN Platform module, Platform.OS.

For an app built with You.i Platform, calling Platform.OS returns youi as the target platform. As a result, the Metro JavaScript bundler isn’t aware of the actual target platform your app is running on (such as iOS, Android, or Tizen). To create platform-specific code using You.i Platform, you need to use our PlatformConstants module instead.

For example:

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');


See Working with the PlatformConstants Module for reference information on this module.