Skip to main content

bond_notifications 0.2.0 copy "bond_notifications: ^0.2.0" to clipboard
bond_notifications: ^0.2.0 copied to clipboard

Bond package provides a convenient way to handle notifications.

bond_notifications #

Notification building blocks for Flutter Bond apps: push notifications from any number of channels (e.g. Firebase Cloud Messaging) and an in-app notification center backed by your server.

Requires Dart 3.13 / Flutter 3.47 or newer.

Install #

dependencies:
  bond_notifications: ^0.2.0

Push notifications #

Implement PushNotificationProvider for each push channel. It exposes the device token (and apnsToken), onTokenRefresh, and streams of NotificationData (a Map<String, dynamic>): onNotification, onNotificationTapped, onNotificationDismiss and initialNotification.

Combine your channels in PushNotificationsProviders and start listening at app start:

import 'package:bond_core/bond_core.dart';
import 'package:bond_notifications/bond_notifications.dart';

sl.registerLazySingleton<PushNotificationsProviders>(
  () => PushNotificationsProviders(
    pushNotificationProviders: [MyFirebaseMessagingProvider()],
  ),
);

sl<PushNotificationsProviders>().listen();

When a notification is tapped, every registered ServiceProvider that mixes in PushNotificationServiceProviderMixin receives it in handlePushNotificationAction(data), so each feature can route its own notifications.

Notification center #

ServerNotificationsProvider (and NotificationCenterProvider with a NotificationCenterDataSource) loads the user's notifications from your API and exposes notifications and unreadNotificationsCount streams plus load(), read(), readAll() and onTap().

The Flutter Bond template wires both up from its notification config; see lib/providers/notifications_service_provider.dart there.

0
likes
130
points
165
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Bond package provides a convenient way to handle notifications.

License

MIT (license)

Dependencies

bond_core, bond_network, flutter, json_annotation

More

Packages that depend on bond_notifications