diff --git a/ios/Classes/SwiftAlarmPlugin.swift b/ios/Classes/SwiftAlarmPlugin.swift index b3ad9f0c..31ed314b 100644 --- a/ios/Classes/SwiftAlarmPlugin.swift +++ b/ios/Classes/SwiftAlarmPlugin.swift @@ -53,7 +53,9 @@ public class SwiftAlarmPlugin: NSObject, FlutterPlugin { case "isRinging": if let arguments = call.arguments as? [String: Any], let id = arguments["id"] as? Int { - result(self.alarms[id]?.audioPlayer?.isPlaying ?? false) + let isPlaying = self.alarms[id]?.audioPlayer?.isPlaying ?? false + let currentTime = self.alarms[id]?.audioPlayer?.currentTime ?? 0.0 + result(isPlaying && currentTime > 0) } else { result(self.isAnyAlarmRinging()) } diff --git a/lib/src/ios_alarm.dart b/lib/src/ios_alarm.dart index 5b1b4093..31395046 100644 --- a/lib/src/ios_alarm.dart +++ b/lib/src/ios_alarm.dart @@ -112,13 +112,12 @@ class IOSAlarm { /// Checks whether an alarm or any alarm (if id is null) is ringing. static Future isRinging([int? id]) async { try { - final res = await methodChannel.invokeMethod( - 'isRinging', - {'id': id}, - ) ?? - false; + final res = await methodChannel.invokeMethod( + 'isRinging', + {'id': id}, + ); - return res; + return res ?? false; } catch (e) { debugPrint('Error checking if alarm is ringing: $e'); return false;