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 install

Expo 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-plugin

Then replace @batch.com/react-native-plugin" by @batch.com/expo-plugin" in your app.json file:

app.json
  "plugins": [
      [
        //"@batch.com/react-native-plugin",
        "@batch.com/expo-plugin",
        {
          // ...
        }
      ]
    ],

If you were using the configuration field shouldUseNonNullableIntent introduced in v11.1, you can now remove it.

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.

If you are still on the legacy architecture and do not plan to migrate on the new one, please use the Batch-React-Native-Plugin v11.

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:

react-native.config.js
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:

MainApplication.kt
import com.batch.batch_rn.RNBatchModule

override fun 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.gradle file:

build.gradle
defaultConfig {
    // ...
    resValue("bool", "BATCH_DO_NOT_DISTURB_INITIAL_STATE", "true") // Remove this line
}
  • Then add the new flag to your AndroidManifest.xml :

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