Message Center Overview

The default Message Center is available for iOS and Android SDK 7.0.0 or later. 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.

Display message center

MessageCenter.shared().showMessageCenter()
MessageCenter.shared().showMessageCenter();
MessageCenter.shared.display()
[UAMessageCenter.shared display];
UrbanAirship.displayMessageCenter()
Events
Airship.onInboxUpdated
    .listen((event) => debugPrint('Inbox updated'));

Airship.onShowInbox
    .listen((event) => debugPrint('Navigate to app's inbox'));

Airship.onShowInboxMessage
    .listen((messageId) => debugPrint('Navigate to message $messageId'));
Using the InboxMessageView
InboxMessage message = messages[0];

void onInboxMessageViewCreated(InboxMessageViewController controller) {
    controller.loadMessage(message);
}

@override
Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            appBar: AppBar(
            title: const Text('Message: $message.title'),
        ),
        body:  Container(
            child: InboxMessageView(onViewCreated: onInboxMessageViewCreated),
            height: 300.0,
        )
    ));
}
UAirship.displayMessageCenter();
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 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.
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.
// Not supported
// Not supported
// Not supported
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 = MessageCenter.shared.messageList.messages
NSArray *messages = UAMessageCenter.shared.messageList.messages;
UrbanAirship.getInboxMessages().then((data) => {
    console.log('Inbox messages: ', data)
});
List<InboxMessage> messages = await Airship.inboxMessages;
UAirship.getInboxMessages();
var messages = Airship.Instance.InboxMessages;
Airship.messageCenter.messages
Airship.Shared.InboxMessages();

Refresh messages

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

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

});
MessageCenter.shared.messageList.retrieveMessageList(successBlock: {
   // handle success
}, withFailureBlock: {
    // handle failure
})
[UAMessageCenter.shared.messageList retrieveMessageListWithSuccessBlock:^{
    // handle success
} withFailureBlock:^{
    // handle failure
}];
UrbanAirship.refreshInbox().then((result) => {
  console.log('Inbox refreshed: ', result)
}).catch((err) => {
  console.log('Unable to refresh inbox: ', err)
})
Airship.refreshInbox();
UAirship.refreshInbox();
// Not supported in 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();
let message = MessageCenter.shared.messageList.message(forID: messageID)
        MessageCenter.shared.messageList.markMessagesRead([message as Any]) {}
UAInboxMessage *message = [[UAMessageCenter shared].messageList messageForID:messageId];
[[UAMessageCenter shared].messageList markMessagesRead:@[message] completionHandler:^(){}];
UrbanAirship.markInboxMessageRead("message-id").then((result) => {
  console.log('Message marked as read: ', result)
}).catch((err) => {
  console.log('Unable to mark message as read: ', err)
})
Airship.markInboxMessageRead(messages[0]);
UAirship.markInboxMessageRead("theInboxMessageID");
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();
let message = MessageCenter.shared.messageList.message(forID: messageID)
        MessageCenter.shared.messageList.markMessagesDeleted([message as Any]) {}
UAInboxMessage *message = [[UAMessageCenter shared].messageList messageForID:messageId];
 [[UAMessageCenter shared].messageList markMessagesDeleted:@[message] completionHandler:^(){}];
UrbanAirship.deleteInboxMessage("message-id").then((result) => {
  console.log('Message deleted: ', result)
}).catch((err) => {
  console.log('Unable to delete message: ', err)
})
Airship.deleteInboxMessage(messages[0]);
UAirship.deleteInboxMessage("theInboxMessageID");
Airship.Instance.DeleteMessage("message-id")
Airship.messageCenter.deleteMessage("message-id")
Airship.Shared.DeleteInboxMessage("message-id");