Migrating from @bam.tech

Batch React-Native Plugin is now fully developed by Batch. If you were previously using the BAM's plugin please follow this guide.

Remove BAM's plugin

Start by removing the old plugin :

yarn remove @bam.tech/react-native-batch

or using npm :

npm uninstall @bam.tech/react-native-batch

Add Batch's plugin

Now add the dependency to our plugin :

yarn add @batch.com/react-native-plugin

or using npm :

npm install @batch.com/react-native-plugin

Don't forget to re-install pod dependencies (not required if you are using Expo as it will do this for you during the prebuild).

cd ios && pod install

Update references

At this point you have replaced the plugin but you still have references to the old one in your application.

Update React-Native Config

Start by updating your react-native-config.js as following :

module.exports = {
    dependencies: { 
      // Formerly "@bam.tech/react-native-batch",
      '@batch.com/react-native-plugin': {
        platforms: {
          android: {
            packageInstance: 'new RNBatchPackage(this.getApplication())',
          },
        },
      },
    },
  };

Update Config Plugins (Expo only)

This step is requires only if you are using Expo in your project. Update your application configuration file as following :

// app.json/app.config.js

{
  "expo": {
    ...,
    "plugins": [
      [
        // Formerly "@bam.tech/react-native-batch",
        "@batch.com/react-native-plugin",
        {
          "androidApiKey": "YOUR_ANDROID_BATCH_API_KEY",
          "iosApiKey": "YOUR_IOS_BATCH_API_KEY",
          "enableDoNotDisturb": false // Optionnal (default: false)
        }
      ]
    ]
  }
}

Don't forget to run the expo prebuild --clean command to rebuild the app with the plugin changes.

Native dependencies

If you are using Expo into your application, you can directly jump to the Replace JS imports step.

Android

The Batch React-Native plugin now uses the Android Batch SDK as transitive depency, so if you had previously added Batch as dependency directly in your build.gradle file, please remove it.

// android/app/build.gradle

dependencies {
    ...
    // Remove this 
    // implementation "com.batch.android:batch-sdk:${rootProject.ext.batchSdkVersion}"
    ...
}

apply plugin: 'com.google.gms.google-services'

Since the Batch Native SDK is accessible as transitive dependency, it's no longger necessary to override the version so please remove it.

// android/build.gradle

buildscript {
    ...
    ext {
        // Remove this line or the all 'ext' block if Batch is the only extra property used.
        batchSdkVersion = '1.17+'
    }
    dependencies {
        ...
    }
}

iOS

Just ensure you are not overriding the ios native sdk version in your podfile. Please open ios/Podfile and remove the line pod 'Batch', '~>1.19' if present.

If it was the case, please run in a terminal:

cd ios && pod update Batch

If you had overrided the Batch native sdk version for a specific use case, please refer to our overriding sdk version guide.

Replace JS imports

The last step you need to do is to replace all your javascript imports to the old plugin with the one.

Example:

// Replace this line 
import { BatchPush } from '@bam.tech/react-native-batch';

// By this one
import { BatchPush } from '@batch.com/react-native-plugin';

Once you have replaced all references, you can just run your application as always.

If you had a running instance of your Metro server, don't forget to restart it using the --reset-cache option.