getDeliveredNotifications method
Gets all delivered notifications from both repositories.
Implementation
Future<(NotificationFailure?, List<NotificationEntity>?)>
getDeliveredNotifications() async {
if (!_isInitialized) {
return (
NotificationFailure.initialization(
details: 'Notification manager not initialized',
),
null,
);
}
// Get from both repositories and merge
final (
NotificationFailure? localError,
List<NotificationEntity>? localNotifications,
) = await _localRepository
.getDeliveredNotifications();
final (
NotificationFailure? firebaseError,
List<NotificationEntity>? firebaseNotifications,
) = await _firebaseRepository
.getDeliveredNotifications();
// Merge results
final List<NotificationEntity> allNotifications = <NotificationEntity>[
...?localNotifications,
...?firebaseNotifications,
];
// Return first error if any, otherwise success with merged notifications
return (
localError ?? firebaseError,
allNotifications.isEmpty ? null : allNotifications,
);
}