Push Callbacks

Netmera provides the following push notification callbacks:

  • Push Register: Triggered when a device registers for push notifications.

  • Push Receive: Triggered when a push notification is received.

  • Push Open: Triggered when a user taps the notification.

  • Push Dismiss ( only Android ): Triggered when a user dismisses the notification.

  • Push Button Click: Triggered when a user interacts with a button inside the notification.

  • Carousel Object Select: Triggered when a user selects an item in a carousel notification.

To enable these callbacks in your React Native project, follow the steps below:

Step 1: Create NetmeraPushHeadlessTask.ts

  • Create a new file named NetmeraPushHeadlessTask.ts in your React Native project and define the callback functions:

import {
  NetmeraPushObject,
  NetmeraInteractiveAction,
  NetmeraCarouselObject
} from "react-native-netmera";

export const onPushRegister = async (data: { pushToken: string }) => {
  console.log('onPushRegister: ', data);
};

export const onPushReceive = async (push: NetmeraPushObject) => {
  console.log('onPushReceive: ', push);
};

export const onPushOpen = async (push: NetmeraPushObject) => {
  console.log('onPushOpen: ', push);
};

export const onPushDismiss = async (push: NetmeraPushObject) => {
  console.log('onPushDismiss: ', push);
};

export const onPushButtonClicked = async (
  push: NetmeraPushObject,
  action?: NetmeraInteractiveAction
) => {
  console.log('onPushButtonClicked: ', push);
  console.log('Clicked action: ', action);
};

export const onCarouselObjectSelected = async (
  push: NetmeraPushObject,
  carouselItem?: NetmeraCarouselObject
) => {
  console.log('onCarouselObjectSelected: ', push);
  console.log('Selected carousel item: ', carouselItem);
};

Step 2: Register Callbacks in index.js

  • In your index.js file, import the callback functions and call setPushLifecycleCallbacks:

Last updated

Was this helpful?