ข้ามไปยังเนื้อหา

Setting up Message Inbox for React Native

เนื้อหานี้ยังไม่มีในภาษาของคุณ

The Pushwoosh React Native plugin ships Message Inbox (the “bell icon” App Inbox) as part of the same pushwoosh-react-native-plugin package used for push notifications. No extra install step is needed.

Prerequisites

Anchor link to

Show the inbox

Anchor link to
import Pushwoosh from 'pushwoosh-react-native-plugin';
Pushwoosh.presentInboxUI();

presentInboxUI() presents a native screen (a view controller on iOS, an Activity on Android) outside the React view tree, with the SDK’s default appearance.

Customize the style

Anchor link to

Pass a style object to presentInboxUI(). Color values must go through React Native’s processColor(). Every key is optional:

KeyCustomizes
dateFormatDate formatting
defaultImageIconThe default icon next to a message with no image
unreadImageThe unread-messages mark (iOS only)
listErrorImageShown when loading the list fails
listEmptyImageShown when the list has no messages
listErrorMessageError text (not localized)
listEmptyMessageEmpty-list text (not localized)
defaultTextColorDefault text color (iOS only)
accentColorAccent color
backgroundColorBackground color
highlightColorSelection color
titleColorMessage title color
readTitleColorTitle color for read messages (Android only)
descriptionColorMessage description color
readDescriptionColorDescription color for read messages (Android only)
dateColorMessage date color
readDateColorDate color for read messages (Android only)
dividerColorSeparator color
barBackgroundColorThe title bar’s background color
barAccentColorThe title bar’s back-button color
barTextColorThe title bar’s text color
import Pushwoosh from 'pushwoosh-react-native-plugin';
import { processColor } from 'react-native';
Pushwoosh.presentInboxUI({
dateFormat: "dd.MM.yyyy",
accentColor: processColor('#3498db'),
backgroundColor: processColor('#ffffff'),
titleColor: processColor('#333333'),
descriptionColor: processColor('#666666'),
listEmptyMessage: "No messages yet"
});

Manage messages programmatically

Anchor link to

Load the message list, read counts, and act on individual messages without opening the built-in screen. This is useful for a custom inbox UI or an unread badge:

Pushwoosh.loadMessages(
(messages) => {
messages.forEach((msg) => {
console.log(msg.title + ": " + msg.message);
});
},
(error) => console.error("Failed to load: " + error)
);
Pushwoosh.unreadMessagesCount((count) => {
console.log("Unread messages: " + count);
});
Pushwoosh.messagesCount((count) => { /* total messages */ });
Pushwoosh.messagesWithNoActionPerformedCount((count) => { /* not yet acted on */ });
Pushwoosh.readMessage(messageId);
Pushwoosh.deleteMessage(messageId);
Pushwoosh.performAction(messageId); // runs the message's default action, e.g. opening a URL