@@ -38,12 +38,13 @@ class NotificationService: NSObject {
3838 let content = UNMutableNotificationContent ( )
3939 content. title = " Cooldown complete "
4040 content. body = " Time elapsed: \( DateComponentsFormatter . notificationFormatter. string ( from: cooldown. remaining) ?? " ??? " ) "
41- content. sound = . default
42-
41+ content. sound = UNNotificationSound ( named : UNNotificationSoundName ( " ding.wav " ) )
42+
4343 let components = Calendar . current. dateComponents ( [ . year, . month, . day, . hour, . minute, . second] , from: cooldown. target)
4444 let trigger = UNCalendarNotificationTrigger ( dateMatching: components, repeats: false )
4545
46- let request = UNNotificationRequest ( identifier: " cooldown-complete " , content: content, trigger: trigger)
46+ UNUserNotificationCenter . current ( ) . removeAllPendingNotificationRequests ( )
47+ let request = UNNotificationRequest ( identifier: UUID ( ) . uuidString, content: content, trigger: trigger)
4748 UNUserNotificationCenter . current ( ) . add ( request) { error in
4849 if let error = error { print ( error) }
4950 }
@@ -58,7 +59,7 @@ extension NotificationService: UNUserNotificationCenterDelegate {
5859 _ center: UNUserNotificationCenter ,
5960 willPresent notification: UNNotification ,
6061 withCompletionHandler completionHandler: @escaping ( UNNotificationPresentationOptions ) -> Void ) {
61- completionHandler ( . sound)
62+ completionHandler ( [ . sound, . alert ] )
6263 }
6364
6465}
0 commit comments