Define the notification sound name in AppSettings. (#5106)

This commit is contained in:
Doug
2026-02-13 16:36:45 +00:00
committed by GitHub
parent 4ec2516d55
commit 46be78bc75
6 changed files with 10 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ import Version
struct NotificationContentBuilder {
let messageEventStringBuilder: RoomMessageEventStringBuilder
let notificationSoundName: UNNotificationSoundName
let userSession: NSEUserSessionProtocol
/// Process the given notification item proxy
@@ -48,7 +49,7 @@ struct NotificationContentBuilder {
notificationContent.threadIdentifier = threadIdentifier.replacingOccurrences(of: "@", with: "")
MXLog.info("isNoisy: \(notificationItem.isNoisy)")
notificationContent.sound = notificationItem.isNoisy ? UNNotificationSound(named: UNNotificationSoundName(rawValue: "message.caf")) : nil
notificationContent.sound = notificationItem.isNoisy ? .init(named: notificationSoundName) : nil
switch notificationItem.event {
case .none:

View File

@@ -37,6 +37,7 @@ class NotificationHandler {
destination: .notification)
notificationContentBuilder = NotificationContentBuilder(messageEventStringBuilder: eventStringBuilder,
notificationSoundName: settings.notificationSoundName.publisher.value,
userSession: userSession)
}

View File

@@ -231,7 +231,7 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
let content = UNMutableNotificationContent()
content.body = L10n.notificationReceivedWhileOfflineIos
content.badge = originalRequest.content.unreadCount as NSNumber?
content.sound = .init(named: .init("message.caf"))
content.sound = .init(named: settings.notificationSoundName.publisher.value)
let request = UNNotificationRequest(identifier: Self.receivedWhileOfflineNotificationID, content: content, trigger: nil)
UNUserNotificationCenter.current().add(request)