commit 5a68cfa448f6ecbb29a0d4aef3e4a288ab25178b
parent c99aaea5980121a89c7499665fcb5d45faa1f936
Author: Daniel D’Aquino <daniel@daquino.me>
Date: Wed, 15 May 2024 16:47:49 -0700
Fallback push notification suppression while we do not have entitlement
We do not have the ability to suppress push notifications yet (we are
waiting to receive the entitlement from Apple)
In the meantime, attempt to fallback gracefully where possible
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Reviewed-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git 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
}