adk_notifier 0.0.2 copy "adk_notifier: ^0.0.2" to clipboard
adk_notifier: ^0.0.2 copied to clipboard

A Flutter SDK for the ART Real-time Notification Service, supporting history, live events, and push device registration.

ADK Notifier #

A Flutter package for integrating with the ART Real-time Notification Service. This package provides tools for notification history management, live WebSocket updates, and push device registration.

Features #

  • Notification History: List all notifications for a tenant.
  • Real-time Events: Listen for new notifications via WebSocket subscriptions.
  • Unread Management: Track unread counts and mark notifications as read.
  • Push Registration: Register and unregister device tokens for push notifications (e.g., FCM).
  • Notification Sending: Send targeted notifications to specific recipients.

Getting started #

Add adk_notifier to your pubspec.yaml along with the core art_adk package:

dependencies:
  art_adk: ^1.0.5
  adk_notifier: ^0.0.2

Usage #

Initialize the API #

The NotificationsApi is initialized from an existing Adk instance:

import 'package:art_adk/art_adk.dart';
import 'package:adk_notifier/adk_notifier.dart';

final adk = Adk(adkConfig: ...);
final notificationsApi = NotificationsApi.fromAdk(
  adk,
  options: const NotificationsOptions(
    debug: true, 
    apiBaseUrl: "your_base_url", // Optional override
  ),
);

Listen for Real-time Notifications #

final removeListener = await notificationsApi.onNew((notification) {
  print('New notification: ${notification.title}');
  print('Payload: ${notification.data}');
});

// To stop listening later:
// await removeListener();

Load History and Unread Counts #

// Fetch notifications
final result = await notificationsApi.list(
  const ListParams(status: 'unread', limit: 20),
);
print('Total notifications: ${result.total}');

// Get unread count
final count = await notificationsApi.unreadCount();
print('Unread: $count');

Mark as Read #

// Mark specific notifications as read
await notificationsApi.markRead(['notif_id_1', 'notif_id_2']);

// Mark all as read
await notificationsApi.markRead();

Push Device Management #

// Register device for push
await notificationsApi.registerDevice(
  RegisterDeviceInput(
    token: 'FCM_TOKEN',
    platform: 'android',
  ),
);

// List registered devices
final deviceResult = await notificationsApi.listDevices();
print('Registered devices: ${deviceResult.total}');

// Unregister device
await notificationsApi.unregisterDevice('FCM_TOKEN');

Send a Notification #

await notificationsApi.send(
  SendInput(
    recipients: ['user_123'],
    type: 'alert',
    title: 'Hello',
    body: 'This is a test notification',
    data: {'click_action': 'open_settings'},
    channels: ['in_app', 'push'],
    dedupKey: 'unique_request_id_123',
  ),
);

Additional information #

For more documentation on the underlying ART platform, visit docs.arealtimetech.com.

1
likes
160
points
102
downloads

Documentation

Documentation
API reference

Publisher

verified publisherarealtimetech.com

Weekly Downloads

A Flutter SDK for the ART Real-time Notification Service, supporting history, live events, and push device registration.

Homepage

Topics

#notifications #push-notifications #websocket #realtime #art

License

MIT (license)

Dependencies

art_adk, flutter, http

More

Packages that depend on adk_notifier