BatchInboxFetcher class abstract

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 who 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 from the beginning, like in a "pull to refresh" scenario.

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...).

Please MAKE SURE to call BatchInboxFetcher.dispose once you're done with the fetcher (for example, when the user navigates away). This should usually be done in your State's dispose method. Failure to do so will leak memory, as Batch will not know that the associated native object can be released, and the message channel freed.

As BatchInboxFetcher caches answers from the server, instances of this class should be tied to the lifecycle of the UI consuming it (if applicable).

Another reason to keep the object around, is that you cannot mark a message as read with another BatchInboxFetcher instance that the one that gave you the message in the first place, as this relies on internal data structures that are only loaded in memory.

You can also set a upper messages limit, after which BatchInbox will stop fetching new messages, even if you call fetchNextPage.

Constructors

BatchInboxFetcher()

Properties

allNotifications Future<List<BatchInboxNotificationContent>>
Get all of the notifications that have been fetched by this fetcher instance.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

displayNotificationLandingMessage(BatchInboxNotificationContent notification) Future<void>
Display the landing message attached to a BatchInboxNotificationContent. Do nothing if no message is attached.
dispose() → void
Call this once you're finished with this fetcher to release the native object and free all memory. Usually, this should be called in your State's dispose. Due to dart/flutter limitations, not calling this will leak memory.
fetchNewNotifications() Future<BatchInboxFetchResult>
Fetch new notifications. While fetchNextPage() is used to fetch older notifications than the ones currently loaded, this method checks for new notifications. For example, this is the method you would call on initial load, or on a "pull to refresh". The previously loaded notifications will be cleared to ensure consistency. Otherwise, a gap could be created between new notifications and your current set. Upon calling this method, please clear your cache and fill it with this method's results and ask again for more pages if you need.
fetchNextPage() Future<BatchInboxFetchResult>
Fetch a page of notifications. Calling this method when no messages have been loaded will be equivalent to calling fetchNewNotifications;
markAllNotificationsAsRead() Future<void>
Marks all notifications as read. Note: Please refresh your copy of the notifications using allNotifications to update the read status. Calling fetchNewNotifications()/fetchNextPage() right away might cause notifications to come as unread, as the server needs time to process your request.
markNotificationAsDeleted(BatchInboxNotificationContent notification) Future<void>
Marks a notification as deleted.
markNotificationAsRead(BatchInboxNotificationContent notification) Future<void>
Marks a notification as read.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited