Skip to content

Commit

Permalink
[Android] Fix: Alarm rings NOW in DateTime.now (in a difference of 1 …
Browse files Browse the repository at this point in the history
…sec) (#68)

* fix: alarm rings NOW in DateTime.now

* refactor: remove vibrate and enableNotificationOnKill params from ring now
  • Loading branch information
dtkdt100 committed Oct 3, 2023
1 parent 85fa68b commit 34afa06
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/src/android_alarm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ class AndroidAlarm {
throw AlarmException('Isolate error: $e');
}

if (settings.dateTime.difference(DateTime.now()).inSeconds <= 1) {
await playAlarm(id, {
"assetAudioPath": settings.assetAudioPath,
"loopAudio": settings.loopAudio,
"fadeDuration": settings.fadeDuration.toInt(),
});
return true;
}

final res = await AndroidAlarmManager.oneShotAt(
settings.dateTime,
id,
Expand Down

0 comments on commit 34afa06

Please sign in to comment.