Added NotificationID property to Alarm
This commit is contained in:
@@ -51,6 +51,7 @@ class Alarm: Codable
|
||||
var text: String
|
||||
var wakeMethod: WVM
|
||||
var alarmTone: SystemSoundID
|
||||
var notificationID: String
|
||||
|
||||
/// What days does it repeat (Sun, Mon, Tue, Wed, Thu, Fri, Sat)
|
||||
var repeats: [Bool]
|
||||
@@ -74,6 +75,7 @@ class Alarm: Codable
|
||||
self.repeats = repeats
|
||||
self.lastActivate = lastActivate
|
||||
self.alarmTone = alarmTone
|
||||
self.notificationID = "notification.id.\(Int.random(in: 1...Int.max))"
|
||||
}
|
||||
|
||||
/// Does it automatically disable after activating once
|
||||
|
||||
@@ -38,7 +38,7 @@ class Notification {
|
||||
|
||||
// Scheduels alarm notification for proper time
|
||||
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: alarm.nextActivate!.timeIntervalSince(Date()), repeats: false)
|
||||
let request = UNNotificationRequest(identifier: "notification.id.01", content: content, trigger: trigger)
|
||||
let request = UNNotificationRequest(identifier: alarm.notificationID, content: content, trigger: trigger)
|
||||
|
||||
// Sends notification
|
||||
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
|
||||
|
||||
Reference in New Issue
Block a user