From dfcf14d007c8293924ea77058a8bfe3a028ed9f4 Mon Sep 17 00:00:00 2001 From: Gautier de Lataillade <32983806+gdelataillade@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:56:36 +0100 Subject: [PATCH] Call stopAlarm when loop audio is false and audio ends in iOS --- .../main/kotlin/com/gdelataillade/alarm/alarm/AlarmService.kt | 4 +--- example/lib/screens/home.dart | 1 - ios/Classes/SwiftAlarmPlugin.swift | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/android/src/main/kotlin/com/gdelataillade/alarm/alarm/AlarmService.kt b/android/src/main/kotlin/com/gdelataillade/alarm/alarm/AlarmService.kt index c099b042..6af74995 100644 --- a/android/src/main/kotlin/com/gdelataillade/alarm/alarm/AlarmService.kt +++ b/android/src/main/kotlin/com/gdelataillade/alarm/alarm/AlarmService.kt @@ -92,9 +92,7 @@ class AlarmService : Service() { audioService?.setOnAudioCompleteListener { if (!loopAudio!!) { - vibrationService?.stopVibrating() - volumeService?.restorePreviousVolume(showSystemUI) - volumeService?.abandonAudioFocus() + stopAlarm(id) } } diff --git a/example/lib/screens/home.dart b/example/lib/screens/home.dart index bd38bd34..7c53510a 100644 --- a/example/lib/screens/home.dart +++ b/example/lib/screens/home.dart @@ -25,7 +25,6 @@ class _ExampleAlarmHomeScreenState extends State { super.initState(); if (Alarm.android) { checkAndroidNotificationPermission(); - checkAndroidExternalStoragePermission(); } loadAlarms(); subscription ??= Alarm.ringStream.stream.listen( diff --git a/ios/Classes/SwiftAlarmPlugin.swift b/ios/Classes/SwiftAlarmPlugin.swift index 5b521ed1..807e7da5 100644 --- a/ios/Classes/SwiftAlarmPlugin.swift +++ b/ios/Classes/SwiftAlarmPlugin.swift @@ -247,7 +247,7 @@ public class SwiftAlarmPlugin: NSObject, FlutterPlugin { if !audioLoop { let audioDuration = audioPlayer.duration DispatchQueue.main.asyncAfter(deadline: .now() + audioDuration) { - self.vibrate = false + self.stopAlarm(id: id, result: { _ in }) } } @@ -290,7 +290,7 @@ public class SwiftAlarmPlugin: NSObject, FlutterPlugin { } else { result(false) } - } + } private func stopSilentSound() { self.mixOtherAudios()