Message Center Overview

The default Message Center is available for iOS and Android. Minimal integration is required, and basic theming options are supported.

By default, when the app receives a push notification carrying a Message Center Action, the Message Center will be automatically displayed in a modal view controller. The Message Center can also be displayed manually with a simple method call on the UAMessageCenter instance. By wiring this method call to a button in your app, you can quickly produce a user-initiated Message Center with no additional effort.

Message Center inboxes are associated with channel IDs. On Android, reinstalling an app creates a new channel ID. Messages previously available in an Android user’s inbox will no longer be available after app reinstall.

Display message center

MessageCenter.shared().showMessageCenter()
MessageCenter.shared().showMessageCenter();
MessageCenter.shared.display()
[UAMessageCenter.shared display];
await Airship.messageCenter.display();
Airship.messageCenter.display()
Airship.messageCenter.display();
await Airship.messageCenter.display()
using AirshipDotNet;

Airship.Instance.DisplayMessageCenter();
using UrbanAirship.NETStandard;

Airship.Instance.DisplayMessageCenter();
Airship.messageCenter.display();
UAirship.Shared.DisplayMessageCenter();

Override default display

The Airship SDK will default to showing the provided MessageCenterActivity. A custom show behavior can be accomplished by providing a MessageCenter.OnShowMessageCenterListener listener during takeOff:

MessageCenter.shared().setOnShowMessageCenterListener { messageId: String? ->
    // Show the message center (messageId is optional)
    true
}

The Airship SDK will default to showing the provided MessageCenterActivity. A custom show behavior can be accomplished by providing a MessageCenter.OnShowMessageCenterListener listener during takeOff:

MessageCenter.shared().setOnShowMessageCenterListener(messageId -> {
    // Show the message center (messageId is optional)
    return true;
});
For custom Message Center implementations, initialize the MessageCenterDisplayDelegate with the custom Message Center implementation’s view controller. This is necessary to ensure that the modal Message Center is not displayed on top of the custom Message Center when a message is received.
For custom Message Center implementations, initialize the UAMessageCenterDisplayDelegate with the custom Message Center implementation’s view controller. This is necessary to ensure that the modal Message Center is not displayed on top of the custom Message Center when a message is received.

First disable the OOTB UI for Message Center.

Airship.messageCenter.setAutoLaunchDefaultMessageCenter(false);

When disabled, the plugin will generate DisplayMessageCenter events instead of showing any OOTB UI when the Message Center is requested to display.

Next, add a listener to handle the display events:

  Airship.addListener(EventType.DisplayMessageCenter, (event) => {
    if (event.messageId) {
      // deep link to message
    } else {
      // deep link to message center
    }
  });

First disable the OOTB UI for Message Center.

  Airship.messageCenter.setAutoLaunchDefaultMessageCenter(false);

When disabled, the plugin will generate display events instead of showing any OOTB UI when the Message Center is requested to display.

Next, add a listener to handle the display events:

Airship.messageCenter.onDisplay
    .listen((event) => debugPrint('Navigate to app's inbox $event'));
  Airship.messageCenter.setAutoLaunchDefaultMessageCenter(false);

When disabled, the plugin will generate DisplayMessageCenter events instead of showing any OOTB UI when the Message Center is requested to display. Use Airship.messageCenter.showMessageView to show the actual content of the message in an overlay.

Next, add a listener to handle the display events:

  Airship.messageCenter.onDisplay((event) => {
    if (event.messageId) {
      // deep link to message
    } else {
      // deep link to message center
    }
  });
await Airship.messageCenter.setAutoLaunchDefaultMessageCenter(false)

When disabled, the plugin will generate DisplayMessageCenter events instead of showing any OOTB UI when the Message Center is requested to display. Use Airship.messageCenter.showMessageView to show the actual content of the message in an overlay.

Next, add a listener to handle the display events:

await Airship.messageCenter.onDisplay(event => {
    if (event.messageId) {
        // deep link to message 
    } else {
        // deep link to message center
    }
});
using AirshipDotNet;

Airship.Instance.OnMessageCenterDisplay += OnMessageCenterDisplay;

static void OnMessageCenterDisplay(object sender, MessageCenterEventArgs e)
{
    // Navigate to custom UI
}
using UrbanAirship.NETStandard;

Airship.Instance.OnMessageCenterDisplay += OnMessageCenterDisplay;

static void OnMessageCenterDisplay(object sender, MessageCenterEventArgs e)
{
    // Navigate to custom UI
}
// Not supported
// Not supported

Fetch messages

val messages = MessageCenter.shared().inbox.messages
MessageCenter.shared().getInbox().getMessages();
let messages = await MessageCenter.shared.inbox.messages
[UAMessageCenter.shared.inbox getMessagesWithCompletionHandler:^(NSArray<UAMessageCenterMessage *> *messages) {
    // handle messages
}];
const messages = await Airship.messageCenter.getMessages();
List<InboxMessage> messages = await Airship.messageCenter.messages;
  Airship.messageCenter.getMessages((messages) => {
    console.log('Inbox messages: + messages);
  });
const messages = await Airship.messageCenter.getMessages()
using AirshipDotNet;

var messages = Airship.Instance.InboxMessages;
using UrbanAirship.NETStandard;

Airship.Instance.InboxMessages(messages =>
{

});
Airship.messageCenter.messages
Airship.Shared.InboxMessages();

Refresh messages

MessageCenter.shared().inbox.fetchMessages { success ->

}
MessageCenter.shared().getInbox().fetchMessages(new Inbox.FetchMessagesCallback() {

});
let refreshed = await MessageCenter.shared.inbox.refreshMessages()
[UAMessageCenter.shared.inbox refreshMessagesWithCompletionHandler:^(BOOL result) {
    // handle result
}];
try {
    await Airship.messageCenter.refreshMessages();
} catch (error) {
    console.log('Unable to refresh inbox: ', error);
}
Airship.messageCenter.refreshInbox();
 Airship.messageCenter.refreshMessages(
    () => {
      console.log('Refreshed');
    },
    (error) => {
      console.log('Failed: " + error);
    }
 );
await Airship.messageCenter.refreshMessages()
Airship.Instance.FetchInboxMessages(success =>
{
   // ...
});
// Not supported in Airship .NETStandard library. Use native binding methods instead.
// Not supported
Airship.Shared.RefreshInbox()

Mark message read

MessageCenter.shared().inbox.markMessagesRead(setOf(messageId))
Message message = MessageCenter.shared().getInbox().getMessage(messageId);
message.markRead();
await MessageCenter.shared.inbox.markRead(messageIDs: [messageID])
[UAMessageCenter.shared.inbox markReadWithMessageIDs:@[messageID] completionHandler:^{
    // Marked read
}];
try {
    await Airship.messageCenter.markMessageRead('message-id');
} catch(error) {
    console.log('Unable to mark message as read: ', error);
}
Airship.messageCenter.markRead("message-id");
Airship.messageCenter.markRead("message-id");
await Airship.messageCenter.markMessageRead("message-id")
using AirshipDotNet;

Airship.Instance.MarkMessageRead("message-id");
using UrbanAirship.NETStandard;

Airship.Instance.MarkMessageRead("message-id");
Airship.messageCenter.markMessageRead("message-id")
Airship.Shared.MarkInboxMessageRead("message-id");

Delete message

MessageCenter.shared().inbox.markMessagesDeleted(setOf(messageId))
Message message = MessageCenter.shared().getInbox().getMessage(messageId);
message.delete();
await MessageCenter.shared.inbox.delete(messageIDs: [messageID])
[UAMessageCenter.shared.inbox deleteWithMessageIDs:@[messageID] completionHandler:^{
    // Deleted
}];
try {
    await Airship.messageCenter.deleteMessage('message-id');
} catch(error) {
    console.log('Unable to delete message: ', error);
}
Airship.messageCenter.deleteMessage("message-id");
Airship.messageCenter.deleteMessage("message-id");
await Airship.messageCenter.deleteMessage("message-id")
using AirshipDotNet;

Airship.Instance.DeleteMessage("message-id");
using UrbanAirship.NETStandard;

Airship.Instance.DeleteMessage("message-id");
Airship.messageCenter.deleteMessage("message-id")
Airship.Shared.DeleteInboxMessage("message-id");

Filtering by Named User

Message Center inboxes populate based on the Channel IDAn Airship-specific unique identifier used to address a channel instance, e.g., a smartphone, web browser, email address. for a device. If two users log in to an app on the same device, all messages sent to either user appear in the Message Center inbox.

You can set up filtering by Named UserA customer-provided identifier used for mapping multiple devices and channels to a specific individual. so that when users log in with different accounts, they only see messages for the current account.

In your app’s Message Center, add a filter for the Named UserA customer-provided identifier used for mapping multiple devices and channels to a specific individual. associated with the logged-in user. See:

When creating Message Center messages, include a Custom KeyAdditional key-value pairs in your push notification payload for use by custom code in your app or website. You can use custom keys to pass additional campaign identifiers for analytics, pass user information to the device, control the look and feel of the app, provide image links, etc. with named_user_id as the key and the user’s actual ID as the value.

Message Center behavior with filtering for users User A and User B logging into an app on the same device:

  • If you target User A in a message while they are logged in, the message will appear in the inbox.
  • If you target User B in a message while they are logged in, the message will appear in the inbox.
  • If you target User A or User B while the other is logged in, the message will not appear in the inbox.
  • If you target User A or User B while neither is logged in, the message will not appear in the inbox.