diff --git a/DamusNotificationService/NotificationService.swift b/DamusNotificationService/NotificationService.swift index 4d3e8c46..b82a5e73 100644 --- a/DamusNotificationService/NotificationService.swift +++ b/DamusNotificationService/NotificationService.swift @@ -40,15 +40,32 @@ class NotificationService: UNNotificationServiceExtension { return } + // Don't show notification details that match mute list. + // TODO: Remove this code block once we get notification suppression entitlement from Apple. It will be covered by the `guard should_display_notification` block + if state.mutelist_manager.is_event_muted(nostr_event) { + // We cannot really suppress muted notifications until we have the notification supression entitlement. + // The best we can do if we ever get those muted notifications (which we generally won't due to server-side processing) is to obscure the details + let content = UNMutableNotificationContent() + content.title = NSLocalizedString("Muted event", comment: "Title for a push notification which has been muted") + content.body = NSLocalizedString("This is an event that has been muted according to your mute list rules. We cannot suppress this notification, but we obscured the details to respect your preferences", comment: "Description for a push notification which has been muted, and explanation that we cannot suppress it") + content.sound = UNNotificationSound.default + contentHandler(content) + return + } + guard should_display_notification(state: state, event: nostr_event) else { // We should not display notification for this event. Suppress notification. - contentHandler(UNNotificationContent()) + // contentHandler(UNNotificationContent()) + // TODO: We cannot really suppress until we have the notification supression entitlement. Show the raw notification + contentHandler(request.content) return } guard let notification_object = generate_local_notification_object(from: nostr_event, state: state) else { // We could not process this notification. Probably an unsupported nostr event kind. Suppress. - contentHandler(UNNotificationContent()) + // contentHandler(UNNotificationContent()) + // TODO: We cannot really suppress until we have the notification supression entitlement. Show the raw notification + contentHandler(request.content) return }