Vanilla Integration

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

Installation


Start installing the Batch React-Native plugin with the package manager of your choice:

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

Android extra steps


Starting the SDK

Update your MainApplication file as following:

MainApplication.kt
import com.batch.batch_rn.RNBatchModule

class MainApplication : Application(), ReactApplication {
    // ...
    override fun onCreate() {
        super.onCreate()
        // ...
        // Start Batch Plugin
        RNBatchModule.initialize(this)
    }
}

Configuring onNewIntent

Add the following in your MainActivity :

Install dependencies

Setup the required dependencies in gradle scripts:

Firebase config

Add your google-services.json file to android/app.

Small push notification icon

Follow the Customizing Batch notifications guide to display your notification icon correctly on Android.

iOS extra steps


Install dependencies

As Batch React-Native plugin integrate the iOS Batch SDK, you have to install native dependencies.

Start the SDK

Add the following in your AppDelegate:

Enable Push Capabilities

Open the .xcworkspace in the ios folder. The in the project window:

  • Select your project in the sidebar

  • Go to Signing & Capabilities

  • Press on + Capability

  • Add Push Notifications

Setting up your APIKey


iOS

Edit your Info.plist and add the following:

Android

Edit your android/app/build.gradle and add:

YOUR_BATCH_API_KEY is your SDK API Key. You'll find it in Settings → General

Enable push notifications

Add the following in your app code, ideally the first view a user sees when opening the app:

Last updated