Merge pull request #278 from RyanRory/respect-pn-settings

Respect User Notification Settings
This commit is contained in:
Niels Andriesse 2020-09-23 16:26:54 +10:00 committed by GitHub
commit ab74bd2b34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -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 {