Integrating a NativeModule in a pluggable widget or JS action

0
following this guide: https://reactnative.dev/docs/native-modules-ios I’m trying to add a Native Module into a pluggable widget or JS action. after some trial and error and a couple of attempts I keep getting an error “null is not an object (evaluating 'MultiScanModule.initializeSDK')”  code from a JS Action: // This file was generated by Mendix Studio Pro. // // WARNING: Only the following code will be retained when actions are regenerated: // - the import list // - the code between BEGIN USER CODE and END USER CODE // - the code between BEGIN EXTRA CODE and END EXTRA CODE // Other code you write will be lost the next time you deploy the project. import { Big } from "big.js"; // BEGIN EXTRA CODE import { NativeModules } from 'react-native'; const {MultiScanModule} = NativeModules; // END EXTRA CODE /** * @param {string} token * @returns {Promise.<void>} */ export async function InitAhiSdk(token) { // BEGIN USER CODE MultiScanModule.initializeSDK(); throw new Error("JavaScript action was not implemented"); // END USER CODE } I think it’s null because the pluggable widgets and JS actions are built in the mendix project en the Ntive Module in the Rect Native project. Is there a way to make these Modules that are not NPM packages available to be used from pluggable widgets and JS actions?  Please point to some other tutorials/examples/docs that can help me out.
asked
1 answers
0

I didn't see an npm-install command anywhere in the tutorial you linked.

In your pluggable widget code directory, you should have a node-modules folder where npm packages are installed. in there, if you run an npm-install for that package, it should be available for import in your custom widget. For the project as a whole for use in JS actions, you can check this out which follows the same idea as long as the library is linked/imported into the right place: 

https://docs.mendix.com/howto/extensibility/create-native-javascript-action/#auto-linking

answered