Migrating from v11
Batch React-Native Plugin v12 is a major release which introduces important breaking changes from 11.x. This guide describes how to update your application when using a previous version.
Upgrading the SDK version
To upgrade from v11 to v12, you need to change the SDK version to 12.0.0 in your package.json and then run:
yarn installnpm installExpo support
This version removed support of Expo from the @batch.com/react-native-plugin package. A new dedicated plugin has been added to manage Expo integration.
So, if your application use Expo, please install the new npm package:
npx expo install @batch.com/expo-pluginDo not remove the @batch.com/react-native-plugin dependency from your package.json. The expo-plugin is only a config plugin designed to automatically set up the native configuration for the Batch React-Native-Plugin during the expo pre-build.
Then replace @batch.com/react-native-plugin" by @batch.com/expo-plugin" in your app.json file:
"plugins": [
[
//"@batch.com/react-native-plugin",
"@batch.com/expo-plugin",
{
// ...
}
]
],If you want to run your app locally, do not forget to run the expo prebuild --clean command to rebuild the app with the plugin changes.
Core migration
Legacy Architecture
Batch-React-Native-Plugin is now a pure Turbo Module and does not support the legacy architecture anymore since react-native is freezing the legacy architecture codebase and React-Native 0.82 no longer allows opting out, and Expo SDK 54 is the final release to include it.
React Native CLI
Batch no longer requires a custom React Native CLI configuration anymore.
If react-native.config.js only exists for Batch in your project, please delete it or remove the @batch.com/react-native-plugin entry:
module.exports = {
dependencies: {
// Remove from here
'@batch.com/react-native-plugin': {
platforms: {
android: {
packageInstance: 'new RNBatchPackage(this.getApplication())',
},
},
},
// To here
},
};
Android specifics
If you are using Expo, you can skip this section.
SDK Integration
Since the react-native cli configuration has been removed, you have to manually initialize the sdk from your Android native project to complete your setup.
Please update your MainApplication file as following:
import com.batch.batch_rn.RNBatchModule
override fun onCreate() {
super.onCreate()
// ...
RNBatchModule.initialize(this)
}import com.batch.batch_rn.RNBatchModule
@Override
public void onCreate() {
super.onCreate();
// ...
RNBatchModule.initialize(this);
}Do Not Disturb (DnD)
The initial state of the "Do Not Disturb" (DnD) feature is no longer read from the Android resources. You should now add a meta-data tag batch_do_not_disturb_initial_state to the <application> section of your AndroidManifest.
So if your application enable the initial DnD state, please update as following :
Start by removing the old configuration field from your
build.gradlefile:
defaultConfig {
// ...
resValue("bool", "BATCH_DO_NOT_DISTURB_INITIAL_STATE", "true") // Remove this line
}Then add the new flag to your
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
...
<application android:name=".MainApplication" ...>
...
<meta-data android:name="batch_do_not_disturb_initial_state" android:value="true"/>
</application>
</manifest>To see in details what's precisely changed since v11 please consult our changelog.
Last updated

