Skip to main content

Native Modules

Where should you store the code?

There are a number of Native Modules in the project. Small, project-specific modules can be included directly in the project repository, with the rest of the code, however larger or more complex modules should be extracted and published as internal NPM packages and installed through the private @technology namespace.

Creating a Node package for the Native Module

[⚠️ Missing info! If you have knowledge that covers this topic, help the chapter out by contributing some notes here]

Android Native Modules

Create your module by following the instructions in the React Native docs. Packages follow the naming convention of: GVC{ModuleName}. Then register your package in MainApplication.java like so:

packages.add(new EntainModuleNamePackage());

Your package is then usable as a property of NativeModules:

import { NativeModules } from 'react-native'
...
const { ModuleName } = NativeModules;
const x = await ModuleName.method()

iOS Native Modules

[⚠️ Missing info! If you have knowledge that covers this topic, help the chapter out by contributing some notes here]