React Native Bundle Deployment
React Configurationβ
-
Install dependencies.
npm install --save @tingyunapp/react-native-tingyunapp -
Configure Transform.
-
If the React Native version is greater than or equal to 0.59, add transformer.babelTransformerPath in the transformer of metro.config.js in the root directory.
-
If the React Native version is 0.57 or 0.58, add transformer.babelTransformerPath in the transformer of rn-cli.config.js in the root directory, as shown below:
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
babelTransformerPath: require.resolve('@tingyunapp/react-native-tingyunapp/src/NBSTransformer.js'),
},
};Note: If the project uses react-native bundle packaging and configures the --config parameter, please add transformer.babelTransformerPath in the configured js file.
-
If the React Native version is less than 0.57, create
rn-cli.config.jsin the project root directory (if this file does not exist) and add the following content:module.exports = {
getTransformModulePath() {
return require.resolve('@tingyunapp/react-native-tingyunapp/src/NBSTransformer.js');
},
getSourceExts() {
return ['js'];
}
}Note: If the project uses react-native bundle packaging and configures the --config parameter, please add getTransformModulePath in the configured js file.
-
Android Native Project Configurationβ
For React Native versions below 0.60, SDK bridge method classes may not be packaged into the apk. You can solve this through the following method:
Copy the SDK bridge classes to the Android Native project.
Copy RNReactNativeTingyunappModule.java and RNReactNativeTingyunappPackage.java from node_modules\@tingyunapp\react-native-tingyunapp\android\src\main\java\com\tingyun\app to the Native project
When defining the ReactNativeHost object, add the Tingyun ReactPackage.
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new com.tingyun.app.RNReactNativeTingyunappPackage()// Add Tingyun ReactPackage
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};