BatchInboxFetcher

BatchInboxFetcher allows you to fetch notifications that have been sent to a user (or installation, more on that later) in their raw form, allowing you to display them in a list, for example. This is also useful to display messages to users that disabled notifications.

Once you get your BatchInboxFetcher instance, you should call fetchNewNotifications to fetch the initial page of messages: nothing is done automatically. This method is also useful to refresh the list.

In an effort to minimize network and memory usage, messages are fetched by page (batches of messages): this allows you to easily create an infinite list, loading more messages on demand. While you can configure the maximum number of messages you want in a page, the actual number of returned messages can differ, as the SDK may filter some of the messages returned by the server (such as duplicate notifications, etc...).

As BatchInboxFetcher caches answers from the server, instances of this class should be tied to the lifecycle of the UI consuming it (if applicable). For example, you should keep a reference to this object during your Activity's entire life. Another reason to keep the object around, is that you cannot mark a message as read with another BatchInbox instance that the one that gave you the message in the first place.

A BatchInboxFetcher instance will hold to all fetched messages: be careful of how long you're keeping the instances around. You can also set a upper messages limit, after which BatchInbox will stop fetching new messages, even if you call fetchNextPage.

Note: You will always be called back on the thread that you instantiated BatchInboxFetcher on. use setHandlerOverride if you want to change that behaviour.

Types

Functions

Link copied to clipboard
Link copied to clipboard
Fetch a page of notifications.
Link copied to clipboard
Returns a copy of all notifications that have been fetched until now, ordered by reverse chronological order (meaning that the first message is the newest one, and the last one the oldest).
Link copied to clipboard
open fun hasMore(): Boolean
Returns whether all of the user or installation's notifications have been fetched.
Link copied to clipboard
open fun markAllAsRead()
Marks all notifications as read.
Link copied to clipboard
Mark a specific notification as deleted.
Link copied to clipboard
Mark a specific notification as read.
Link copied to clipboard
open fun setFetchLimit(fetchLimit: Int)
Maximum number of notifications to fetch.
Link copied to clipboard
open fun setFilterSilentNotifications(filterSilentNotifications: Boolean)
Sets whether the SDK should filter silent notifications (pushes that don't result in a message being shown to the user).
Link copied to clipboard
open fun setHandlerOverride(@NonNull handler: Handler)
Specify a handler to post the callbacks on.
Link copied to clipboard
open fun setMaxPageSize(maxPageSize: Int)
Number of notifications to fetch on each call, up to 100 messages per page.