Customizing notifications

Batch allows you to customize your notifications adding specific keys to the payload or by setting some configuration in native code.

Advanced notification configuration is highly OS-specific and requires implementation at a lower level than React-Native.
Therefore, you might find what you want in the native documentations for each OS:

Small push notification icon

In order to make sure that users understand that your notifications come from your app, you need to setup a Small Icon and Notification Color. An icon can be generated using Android Studio's asset generator: as it will be tinted and masked by the system, only the alpha channel matters and will define the shape displayed. It should be of 24x24dp size. If your notifications shows up in the system statusbar in a white shape, this is what you need to configure.

This can be configured in the manifest as metadata in the application tag:

<!-- Assuming there is a push_icon.png in your res/drawable-{dpi} folder -->

<manifest ...>
    <application ...>
        <meta-data
            android:name="com.batch.android.push.smallicon"
            android:resource="@drawable/push_icon" />

        <!-- Notification color. ARGB but the alpha value can only be FF -->
        <meta-data
            android:name="com.batch.android.push.color"
            android:value="#FF00FF00" />

Disabling foreground notifications

By default, the Batch React-Native plugin will always show foreground notifications on both platforms.

The SDK exposes a method on BatchPush to change this behaviour on iOS only:

import { BatchPush } from '@batch.com/react-native-plugin';
BatchPush.setShowForegroundNotification(false);

Note: Disabling foreground notifications on iOS will automatically trigger mobile landings when attached to a push received while the App is in foreground. You can have the same behaviour on android by using the native API Batch.Messaging.setShowForegroundLandings(true) but the sdk will still display foreground notifications when no landing is attached.

Adding notification actions

Notification actions are supported but they integration differ greatly between iOS and Android. Please see the native documentations for more info:

Overriding the notification channel on Android

It is possible to override the default notification channel on Android either globally on a per notification basis.

As this is an operation that needs to be done by native code in the background when React-Native isn't running, please follow our native channels documentation.