pushNotification method
Future<void>
pushNotification({
- required String roomId,
- required String msgId,
- required ChatNotification notification,
override
Implementation
@override
Future<void> pushNotification({
required String roomId,
required String msgId,
required ChatNotification notification,
}) async {
if (me.isEmpty) return;
if (notification.title == null || notification.body == null) return;
final target = room(roomId);
if (target.isEmpty) return;
final sender = await notification.sender?.call() ?? profileFor(me);
for (final participant in target.participants) {
if (participant == me) continue;
if (target.mutes.contains(participant)) continue;
try {
final receiver = profileFor(participant);
if (receiver is! UserProfile) continue;
if (receiver.isEmpty || receiver.isActiveRoom(roomId)) continue;
final allowed = await _isNotificationAllowed(
notification,
participant,
target,
receiver,
);
if (!allowed) continue;
await notificationDelegate.sendNotification(
ChatNotificationContent(
id: msgId,
roomId: roomId,
title: notification.title!,
body: notification.body!,
token: receiver.token,
platform: receiver.platform,
profile: sender,
),
);
} catch (e) {
debugPrint('[NotificationMixin] failed for $participant: $e');
}
}
}