From 27065619d2a7a3f69a575451c79f7492c4639b8a Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Tue, 14 Feb 2023 08:58:01 +0100 Subject: [PATCH] Only add notification target account if more than one account --- IceCubesNotifications/NotificationService.swift | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/IceCubesNotifications/NotificationService.swift b/IceCubesNotifications/NotificationService.swift index c878c309..90cc5e7e 100644 --- a/IceCubesNotifications/NotificationService.swift +++ b/IceCubesNotifications/NotificationService.swift @@ -55,7 +55,9 @@ class NotificationService: UNNotificationServiceExtension { } bestAttemptContent.title = notification.title - bestAttemptContent.subtitle = bestAttemptContent.userInfo["i"] as? String ?? "" + if AppAccountsManager.shared.availableAccounts.count > 1 { + bestAttemptContent.subtitle = bestAttemptContent.userInfo["i"] as? String ?? "" + } bestAttemptContent.body = notification.body.escape() bestAttemptContent.userInfo["plaintext"] = plaintextData bestAttemptContent.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "glass.caf")) @@ -82,8 +84,13 @@ class NotificationService: UNNotificationServiceExtension { if let remoteNotification = await toRemoteNotification(localNotification: notification) { let intent = buildMessageIntent(remoteNotification: remoteNotification, avatarURL: fileURL) bestAttemptContent = try bestAttemptContent.updating(from: intent) as! UNMutableNotificationContent - let newBody = "\(bestAttemptContent.userInfo["i"] as? String ?? "") \n\(notification.title)\n\(notification.body.escape())" - bestAttemptContent.body = newBody + if AppAccountsManager.shared.availableAccounts.count > 1 { + let newBody = "\(bestAttemptContent.userInfo["i"] as? String ?? "") \n\(notification.title)\n\(notification.body.escape())" + bestAttemptContent.body = newBody + } else { + let newBody = "\(notification.title)\n\(notification.body.escape())" + bestAttemptContent.body = newBody + } } else { if let attachment = try? UNNotificationAttachment(identifier: filename, url: fileURL, options: nil) { bestAttemptContent.attachments = [attachment]