Base Service

  • The base service file provides the foundation for implementing different internal notification services. It defines the InternalNotificationsService abstract class, which outlines the required methods and properties that specific services must implement.

Here's an overview of the class structure:

InternalNotificationsService Class

  • The InternalNotificationsService abstract class serves as a blueprint for internal notification services. It provides the members listed here.

Implementing Internal Notifications Service

To create a specific internal notifications service, follow these steps:

  1. Create a new service file that implements the InternalNotificationsService abstract class.
  2. Override the empty methods (init(), dispose(), subscribe(), unsubscribe(), push()) according to the requirements of your chosen service provider (e.g., We have already provided code for services like: Firebase and Pusher. You can refere that when you try to implement your own service).
  3. Customize the properties (pendingNotificationsCountStream, notificationsStream, notifications) to provide the necessary functionality specific to your service.

Source Code

import 'dart:async';

import '../../models/notification.dart';

abstract class InternalNotificationsService {
  final Stream<int> pendingNotificationsCountStream = const Stream.empty();

  final Stream<List<InternalNotification>> notificationsStream = const Stream.empty();

  List<InternalNotification> get notifications => [];

  Future<void> init() async {}

  Future<void> dispose() async {}

  Future<void> subscribe() async {}

  Future<void> unsubscribe() async {}

  Future<void> push(List<String> userIds, InternalNotification notification) async {}

Copyright © 2024