Native Modules Overview

Like Facebook React Native, You.i Engine One lets you write real native code and bind it to JavaScript, extending the functionality of your React Native application.

You.i RN native modules use <youireact/NativeModule.h> and a set of macros such as YI_RN_EXPORT_NAME to bridge from C++ to JavaScript. Depending on your needs, your You.i RN native module can bridge all the way from platform-specific code up to JavaScript.

Note: The macros used to bind native modules are different in You.i Engine One and Facebook React Native. This means that You.i RN native modules can’t be used with Facebook React Native applications, and Facebook RN native modules can’t be used directly with You.i Engine One.

Read more about native module types below, or get a start on writing your own.

Pre-Built RN Native Modules

Made for You.i Engine One

You.i Engine One comes with some built-in native modules such as FormFactor and FairPlay DRM. Our native modules work across all platforms that we support. You can use any of these modules directly, as they’re included in the @youi/react-native-youi namespace.

import {
   FormFactor
} from '@youi/react-native-youi';

Similarly, other pre-built You.i RN native modules (built specifically for You.i Engine One from third parties or other groups at your organization can be directly imported and used in your code. Simply configure the correct namespace in your project’s package.json file and import the desired components.

Be sure to test the native module on all platforms you intend to support. Some third-party native modules may only be applicable to specific platforms.

Third-Party RN Native Modules

You may find there’s functionality you want to add to your application that isn’t part of the usual React Native or You.i Engine One offering. Unfortunately, most third-party RN native modules aren’t supported as-is. The decorators used by Facebook to cast and translate types between languages aren’t supported in You.i Engine One.

If you have the source for a native module, you may be able to use it to help you write your own following the instructions for open source modules below.

Be aware that third-party libraries (such as iOS .framework files or .jar files from Android) are not the same as native modules. These libraries can be linked into your project, then bridged using the processes described in Write a You.i RN Native Module.

Open Source RN Native Modules

As with pre-built RN native modules, only those created specifically for You.i Engine One are supported.

If you have the source code for a generic RN native module, you may be able to convert it.

  1. Replace all the Facebook RCTConvert decorators with your own code that does the translations.
  2. Follow the instructions in Write a You.i RN Native Module to convert the code from using RCT_EXPORT* macros to YI_RN_EXPORT* macros for binding with JavaScript.