Перейти к содержанию

Setting up Message Inbox for Cordova

Этот контент еще не доступен на вашем языке.

The Pushwoosh Cordova plugin ships Message Inbox (the “bell icon” App Inbox) as part of the same pushwoosh-cordova-plugin dependency used for push notifications. No extra install step is needed.

Prerequisites

Anchor link to

Show the inbox

Anchor link to

Call presentInboxUI() on the same pushwoosh object you initialized with cordova.require:

var pushwoosh = cordova.require("pushwoosh-cordova-plugin.PushNotification");
pushwoosh.presentInboxUI();

This opens a native screen (a view controller on iOS, an Activity on Android) with the SDK’s default appearance.

Customize the style

Anchor link to

Pass a style object to presentInboxUI(). 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
barTitleThe inbox screen’s title
barBackgroundColorThe title bar’s background color
barAccentColorThe title bar’s back-button color
barTextColorThe title bar’s text color
pushwoosh.presentInboxUI({
dateFormat: "dd.MM.yyyy",
accentColor: "#3498db",
backgroundColor: "#ffffff",
titleColor: "#333333",
descriptionColor: "#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:

// Array of InboxNotification objects
pushwoosh.loadMessages(function(messages) {
messages.forEach(function(message) {
console.log(message.title + ": " + message.message);
});
}, function(error) {
console.error("Failed to load: " + error);
});
pushwoosh.unreadMessagesCount(function(count) {
console.log("Unread messages: " + count);
});
pushwoosh.messagesCount(function(count) { /* total messages */ });
pushwoosh.messagesWithNoActionPerformedCount(function(count) { /* not yet acted on */ });
pushwoosh.readMessage(messageCode);
pushwoosh.deleteMessage(messageCode);
pushwoosh.performAction(messageCode); // runs the message's default action, e.g. opening a URL