Skip to main content

iOS - Implementing an Inbox

In this page you'll learn how to build an app inbox with all the options at your disposal to create a great messaging experience for your users.

With our library it's extremely easy to implement an in-app inbox. Implementing an inbox increases considerably the engagement rate of your notifications simply because messages will always be available inside your app.

The inbox feature is activated by default by Actito teams when they set-up your integration.

After activating this functionality, you can start implementing your inbox in any view controller of your app.

Device-level inbox

The standard approach is to use the device-level inbox. Each device will have its own independent inbox, regardless of the associated user. The device-level inbox is available via the NotificareInboxKit module. The inbox itself is exposed via the NotificareInboxDelegate, so it is really easy to hook up your view controller to a list of inbox items, for example:

extension InboxViewController: NotificareInboxDelegate {
func notificare(_ notificare: NotificareInbox, didUpdateInbox items: [NotificareInboxItem]) {
// Do something with the items.
}
}

In the same way, you can listen for the number of unread messages.

extension InboxViewController: NotificareInboxDelegate {
func notificare(_ notificare: NotificareInbox, didUpdateBadge badge: Int) {
// Do something with the badge.
}
}

If you want to get the data at any point in time, you can still get the items and the badge in the inbox.

// Items
Notificare.shared.inbox().items

// Badge
Notificare.shared.inbox().badge

Managing inbox items

Assuming that you hold a reference to an item, to open an inbox item you would simply do something like this:

let item: NotificareInboxItem

Notificare.shared.inbox().open(item) { result in
switch result {
case let .success(notification):
// Optional: Present the notification with Push UI.
Notificare.shared.pushUI().presentNotification(notification)
break

case let .failure(error):
// handle the error
break
}
}

To remove items from the inbox you would invoke the following method:

let item: NotificareInboxItem

Notificare.shared.inbox().remove(item) { result in

}

Additionally, you can also mark a message as read by invoking the following method:

let item: NotificareInboxItem

Notificare.shared.inbox().markAsRead(item) { result in

}

Or mark all messages as read by invoking the following method:

Notificare.shared.inbox().markAllAsRead { result in

}

To remove all items in the inbox you would do the following:

Notificare.shared.inbox().clear {

}