React Native SDK
Push notifications
Send push notifications for unread replies through your own push provider.
The SDK has no native code and sends no pushes. When a user has an unread reply, the Mentiora platform sends a message.missed webhook to your backend, and your backend sends the push through APNs or FCM.
Set up
-
Enable the webhook. In Mentiora admin, enable
message.missedunder Integrations → Webhooks. -
Store device tokens by user. The webhook names a signed-in user by
externalUserId(thesubof your identity token) and an anonymous user byinstallRef. GetinstallReffromMentiora.getInstallRef(), and re-key the device token on everyinstallRefChangedevent.nullmeans detach it. -
Send the push. Send an alert push, collapsed by
threadId, with this data block (top-level keys besideapson APNs, insidedataon FCM):JSON{ "mentiora": "1", "threadId": "<threadId from the webhook>" } -
Handle the tap. Pass the push data to
Mentiora.handleNotificationTap(data). It opens the chat on that thread and returnstrue, or returnsfalsefor a push that is not Mentiora's.
Handle taps with expo-notifications
With expo-notifications:
import * as Notifications from "expo-notifications";
import { Mentiora } from "@mentiora-ai/react-native-sdk";
// On iOS, a push sent straight through APNs has its keys in `trigger.payload`.
const dataOf = (n: Notifications.Notification): unknown => {
const { content, trigger } = n.request;
if (Mentiora.isMentioraPush(content.data)) return content.data;
return trigger && "payload" in trigger ? trigger.payload : undefined;
};
const onTap = (response: Notifications.NotificationResponse) => {
Notifications.clearLastNotificationResponse();
Mentiora.handleNotificationTap(dataOf(response.notification));
};
// At the app root: a tap that launched the app, then later taps.
const launch = Notifications.getLastNotificationResponse();
if (launch) onTap(launch);
Notifications.addNotificationResponseReceivedListener(onTap);A tap that cold-starts the app can arrive before configure() runs or <MentioraHost /> mounts. The SDK holds it until both exist.
Badge and background
Your app owns the badge. While the chat page is loaded, keep it current from unreadCountChanged. Otherwise, set it from unreadCount.total in the webhook payload when you send the push.
When the app goes to the background, or the chat is hidden, the chat page is told it is hidden and stays loaded. It is told again when it is shown.