From 62d730ea30320e2f1f6bafe762c6ea9ede904209 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Mon, 5 Sep 2022 15:44:42 +1000 Subject: [PATCH] fix call notification title and content --- Session/Notifications/AppNotifications.swift | 15 +++++---------- .../NSENotificationPresenter.swift | 11 ++++------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Session/Notifications/AppNotifications.swift b/Session/Notifications/AppNotifications.swift index d6d51b294..d2e5a0829 100644 --- a/Session/Notifications/AppNotifications.swift +++ b/Session/Notifications/AppNotifications.swift @@ -313,24 +313,19 @@ public class NotificationPresenter: NSObject, NotificationsProtocol { AppNotificationUserInfoKey.threadId: thread.id ] - let notificationTitle: String = interaction.previewText(db) - let threadName: String = SessionThread.displayName( - threadId: thread.id, - variant: thread.variant, - closedGroupName: nil, // Not supported - openGroupName: nil // Not supported - ) + let notificationTitle: String = "Session" + let senderName: String = Profile.displayName(db, id: interaction.authorId, threadVariant: thread.variant) let notificationBody: String? = { switch messageInfo.state { case .permissionDenied: return String( format: "modal_call_missed_tips_explanation".localized(), - threadName + senderName ) case .missed: return String( format: "call_missed".localized(), - threadName + senderName ) default: return nil @@ -354,7 +349,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol { previewType: previewType, sound: sound, threadVariant: thread.variant, - threadName: threadName, + threadName: senderName, replacingIdentifier: UUID().uuidString ) } diff --git a/SessionNotificationServiceExtension/NSENotificationPresenter.swift b/SessionNotificationServiceExtension/NSENotificationPresenter.swift index 62956ff80..686e6109f 100644 --- a/SessionNotificationServiceExtension/NSENotificationPresenter.swift +++ b/SessionNotificationServiceExtension/NSENotificationPresenter.swift @@ -157,18 +157,15 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol { notificationContent.badge = NSNumber(value: newBadgeNumber) CurrentAppContext().appUserDefaults().set(newBadgeNumber, forKey: "currentBadgeNumber") - notificationContent.title = interaction.previewText(db) + notificationContent.title = "Session" notificationContent.body = "" + let senderName: String = Profile.displayName(db, id: interaction.authorId, threadVariant: thread.variant) + if messageInfo.state == .permissionDenied { notificationContent.body = String( format: "modal_call_missed_tips_explanation".localized(), - SessionThread.displayName( - threadId: thread.id, - variant: thread.variant, - closedGroupName: nil, // Not supported - openGroupName: nil // Not supported - ) + senderName ) }