Skip to content

Commit

Permalink
Ignore current alarm when checking if another alarm is already ringing
Browse files Browse the repository at this point in the history
  • Loading branch information
orkun1675 committed Nov 11, 2024
1 parent c25c4e4 commit 203378d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ios/Classes/SwiftAlarmPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,19 @@ public class SwiftAlarmPlugin: NSObject, FlutterPlugin {
}
return false
}

private func isAnyAlarmRingingExcept(id: Int) -> Bool {
for (_, alarmConfig) in self.alarms {
if alarmConfig.id != id && alarmConfig.triggerTime?.timeIntervalSinceNow ?? 1 <= 0 {
return true
}
}
return false
}


private func handleAlarmAfterDelay(id: Int) {
if self.isAnyAlarmRinging() {
if self.isAnyAlarmRingingExcept(id: id) {
NSLog("[SwiftAlarmPlugin] Ignoring alarm with id \(id) because another alarm is already ringing.")
self.unsaveAlarm(id: id)
return
Expand Down

0 comments on commit 203378d

Please sign in to comment.