Vanilla Integration
Installation
Start installing the Batch React-Native plugin with the package manager of your choice:
yarn add @batch.com/react-native-pluginnpm install @batch.com/react-native-pluginAndroid extra steps
Starting the SDK
Update your MainApplication file as following:
import com.batch.batch_rn.RNBatchModule
class MainApplication : Application(), ReactApplication {
// ...
override fun onCreate() {
super.onCreate()
// ...
// Start Batch Plugin
RNBatchModule.initialize(this)
}
}import com.batch.batch_rn.RNBatchModule
public class MainApplication extends Application implements ReactApplication {
// ...
@Override
public void 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 & CapabilitiesPress on
+ CapabilityAdd
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

