getFetcherForUser method

Future<BatchInboxFetcher> getFetcherForUser(
  1. {required String userIdentifier,
  2. required String authenticationKey,
  3. int? maxPageSize,
  4. int? limit}
)

Get an inbox fetcher for a user identifier.

Set userIdentifier to the identifier for which you want the notifications: this is usually the current user's identifier, set in BatchUser.

The authenticationKey is the secret used to authenticate the request. It should be computed by your backend. See the documentation for more info on how to generate it.

The maxPageSize is the maximum of notifications to fetch on each call, up to 100 messages per page. Note that the actual count of fetched messages might differ from the value you've set here.

Set limit to be the maximum number of notifications to fetch, ever. This allows you to let Batch manage the upper limit itself, so you can be sure not to use a crazy amount of memory.

Implementation

Future<BatchInboxFetcher> getFetcherForUser(
    {required String userIdentifier,
    required String authenticationKey,
    int? maxPageSize,
    int? limit}) async {
  var fetcher = BatchInboxFetcherUserImpl(
      user: userIdentifier, authKey: authenticationKey);
  await fetcher.init(maxPageSize: maxPageSize, limit: limit);
  return fetcher;
}