bjo*_*rnd 29 c++ java android react-native
我有一个C++ React Native模块派生自facebook::xplat::module::CxxModule.它适用于iOS项目,但现在我正试图弄清楚如何从Java中使用它.我找到的唯一文档是React Native代码库中的注释,声明:
其实现是用C++编写的NativeModules不能提供任何Java代码(因此可以在其他平台上重用),而应该使用CxxModuleWrapper注册自己
我的问题是如何使用CxxModuleWrapper在Java中注册C++模块
请查看此博客了解详细信息:https://medium.com/@kudochien/how-to-write-a-react-native-cxxmodule-59073259f15d。博客片段:
extern "C" HelloCxxModule* createHelloCxxModule() {
return new HelloCxxModule();
}
Run Code Online (Sandbox Code Playgroud)
public final class HelloCxxPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(
// I have librnpackage-hellocxx.so the exported createHelloCxxModule() above.
CxxModuleWrapper.makeDso("rnpackage-hellocxx", "createHelloCxxModule")
);
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
701 次 |
| 最近记录: |