From 937c8520f403082ad901416bf827ea48d2b73b90 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Tue, 22 Sep 2020 13:54:58 +1000 Subject: [PATCH] respect notification settings for remote PNs --- .../NotificationServiceExtension.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/LokiPushNotificationService/NotificationServiceExtension.swift b/LokiPushNotificationService/NotificationServiceExtension.swift index 91ea74b55..e62aa882e 100644 --- a/LokiPushNotificationService/NotificationServiceExtension.swift +++ b/LokiPushNotificationService/NotificationServiceExtension.swift @@ -110,7 +110,20 @@ final class NotificationServiceExtension : UNNotificationServiceExtension { newNotificationBody = contentProto?.dataMessage?.body ?? "You've got a new message" } newNotificationBody = handleMentionIfNecessary(rawMessageBody: newNotificationBody, threadID: thread.uniqueId!, transaction: transaction) - notificationContent.body = newNotificationBody + + let notificationPreference = Environment.shared.preferences + if let notificationType = notificationPreference?.notificationPreviewType() { + switch notificationType { + case .nameNoPreview: + notificationContent.body = "New Message!" + case .noNameNoPreview: + notificationContent.title = "" + notificationContent.body = "New Message!" + default: + notificationContent.body = newNotificationBody + } + } + if notificationContent.body.count < 1 { self.completeWithFailure(content: notificationContent) } else {