Skip to main content
This page covers React Native only. For React / Web applications, use @suprsend/react (drop-in components) or @suprsend/react-core (headless) — both use JWT authentication and include interaction-observer based seen tracking. Do not install @suprsend/react-headless for web React apps.The React Native SDK (@suprsend/react-headless) currently uses HMAC subscriber_id authentication as documented below.
The Headless Inbox library provides hooks that can be integrated into React Native components for building inbox, and toast functionality in your applications.

Installation

Initialization

Enclose your app in SuprSendProvider like below and pass the workspace key, distinct_id, and subscriber_id.
SuprSend hooks can only be used inside of SuprSendProvider.

Adding SuprSend inbox component

1) useBell hook

This hook provides unSeenCount, markAllSeen which is related to the Bell icon in the inbox unSeenCount: Use this variable to show the unseen notification count anywhere in your application. markAllSeen: Used to mark seen for all notifications. Call this method on clicking the bell icon so that it will reset the bell count to 0.

2) useNotifications hook

This hook provides a notifications list, unSeenCount, markClicked, markAllSeen. notifications: List of all notifications. This array can be looped and notifications can be displayed. unSeenCount: Use this variable to show the unseen notification count anywhere in your application. markClicked: Method used to mark a notification as clicked. Pass notification id which is clicked as the first param. markAllRead: This method is used to mark all individual notifications as seen. Add a button anywhere in your notification tray as Mark all as read and on clicking of that call this method.

mark all read sample

Notification object structure:

3) useEvent hook

This hook is an event emitter when and takes arguments event type and callback function when the event happens. Must be called anywhere inside SuprSendProvider Handled Events:
  1. new_notification: Called when the new notification occurs can be used to show toast in your application.

Example implementation

Check the example implementation.