mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Log whether a notification is expected to make a noise. (#3782)
* Log whether a notification is expected to make a noise. * Also log the system notification sound setting too.
This commit is contained in:
@@ -17099,6 +17099,70 @@ class UserNotificationCenterMock: UserNotificationCenterProtocol, @unchecked Sen
|
||||
return authorizationStatusReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - notificationSettings
|
||||
|
||||
var notificationSettingsUnderlyingCallsCount = 0
|
||||
var notificationSettingsCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return notificationSettingsUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = notificationSettingsUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
notificationSettingsUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
notificationSettingsUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var notificationSettingsCalled: Bool {
|
||||
return notificationSettingsCallsCount > 0
|
||||
}
|
||||
|
||||
var notificationSettingsUnderlyingReturnValue: UNNotificationSettings!
|
||||
var notificationSettingsReturnValue: UNNotificationSettings! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return notificationSettingsUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: UNNotificationSettings? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = notificationSettingsUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
notificationSettingsUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
notificationSettingsUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var notificationSettingsClosure: (() async -> UNNotificationSettings)?
|
||||
|
||||
func notificationSettings() async -> UNNotificationSettings {
|
||||
notificationSettingsCallsCount += 1
|
||||
if let notificationSettingsClosure = notificationSettingsClosure {
|
||||
return await notificationSettingsClosure()
|
||||
} else {
|
||||
return notificationSettingsReturnValue
|
||||
}
|
||||
}
|
||||
}
|
||||
class UserSessionMock: UserSessionProtocol, @unchecked Sendable {
|
||||
var clientProxy: ClientProxyProtocol {
|
||||
|
||||
@@ -94,6 +94,9 @@ final class NotificationManager: NSObject, NotificationManagerProtocol {
|
||||
self?.delegate?.registerForRemoteNotifications()
|
||||
}
|
||||
}
|
||||
|
||||
let settings = await notificationCenter.notificationSettings()
|
||||
MXLog.info("Notification sound enabled: \(settings.soundSetting == .enabled)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ protocol UserNotificationCenterProtocol: AnyObject {
|
||||
func removeDeliveredNotifications(withIdentifiers identifiers: [String])
|
||||
func setNotificationCategories(_ categories: Set<UNNotificationCategory>)
|
||||
func authorizationStatus() async -> UNAuthorizationStatus
|
||||
func notificationSettings() async -> UNNotificationSettings
|
||||
}
|
||||
|
||||
// sourcery: AutoMockable
|
||||
|
||||
Reference in New Issue
Block a user