Closed bigbossta404 closed 3 weeks ago
Hi @bigbossta404
I think I found the issue. I will fix it in the next release. I'll keep you updated.
I just released version 4.0.7 with a fix. Let me know if it works !
Thanks for the quick fix on this!
Re: cast issues. I've started using pigeon for Flutter <-> Native communication for my packages (e.g. native_geofence) and it has been a life saver. I don't need to copy-paste strings anymore or deal with casts.
I was testing with 4.0.7 today, I'm not seeing a button in the notification, is there supposed to be one?
I also noticed that unlike Android, the notification is not dimissed once the alarm is stopped via code. Is that WAI?
Happy to help contribute code if you could give some pointers.
Hi @orkun1675,
In order to have the stop button in the notification, when setting your alarm, make sure to specify a NotificationSettings .stopButton
like this for example:
final alarmSettings = AlarmSettings(
id: id,
dateTime: selectedDateTime,
loopAudio: loopAudio,
vibrate: vibrate,
volume: volume,
assetAudioPath: assetAudio,
warningNotificationOnKill: Platform.isIOS,
notificationSettings: NotificationSettings(
title: 'Alarm example',
body: 'Your alarm ($id) is ringing',
stopButton: 'Stop the alarm',
icon: 'notification_icon',
),
);
await Alarm.set(alarmSettings: alarmSettings);
Additionally, you need to long-press the notification for the stop button to appear. If the stopButton
param is null then no stop button will be displayed. Then, about:
I also noticed that unlike Android, the notification is not dimissed once the alarm is stopped via code. Is that WAI?
This is indeed an issue I'll have to fix. I've seen the other issues you recently opened and I'll do my best to fix them as fast as possible. Please note that I am the sole developer working on this package in my free time, so it may take a few weeks to address this in the worst-case scenario. I'll keep you updated !
Lastly, if you’re interested in contributing, it would be greatly appreciated. Do you have experience with native iOS (Swift) or Android (Kotlin) development? The code is primarily handled natively to ensure alarm reliability.
Thanks @gdelataillade it was indeed a configuration issue.
I had set stopButton
to null
for iOS because the docstring for the param states:
Won't work on iOS if app was killed.
I guess I was deterred since I got worried about a UX where:
But step (2) shouldn't happen right? So this UX flow is not likely?
Yes, I'm somewhat familiar with Swift and Kotlin. Can help pickup larger bugs that I find. To clarify, I was more so asking about the design pointers (such as guiding me to create a new class X, or update existing class Y to handle Z, etc.).
Hi @orkun1675,
On iOS, step 2 (alarm rings) won’t trigger if the app was killed. A possible improvement could be to reopen the app when the user hits the stop button after it was killed, giving the user a feedback on their action. What do you think ?
To prevent this scenario, you can also prompt users to reopen the app upon termination by using the warningNotificationOnKill
parameter, which can be customized with Alarm.setWarningNotificationOnKill(title, body)
.
For contributing, you shouldn’t need to create new classes. Here’s an overview of the relevant files:
ios/Classes/SwiftAlarmPlugin.swift
, along with related services (storage and notification handling) and models (alarm and notification parameters).AlarmPlugin.kt
, and alarms run as a foreground service in AlarmService.kt
:
• android/src/main/kotlin/com/gdelataillade/alarm/alarm/AlarmPlugin.kt
• android/src/main/kotlin/com/gdelataillade/alarm/alarm/AlarmService.kt
Services and models can be found in adjacent folders for both platforms.
Feel free to reach out if you have any questions—I’m here to help if you decide to dive into it!
Lastly, regarding your observation:
I also noticed that unlike Android, the notification is not dimissed once the alarm is stopped via code?
I’ve addressed the issue in version 4.0.8
.
I think the way the app works now, by warning the user, is great.
If the user kills the app we also should not send a notification since the alarm won't ring.
Thanks for the pointers!
Regarding not sending an alarm notification when the app is killed, I thought it could at least serve as an indicator for the user, letting them know they received something and making them aware they missed the alarm. Showing nothing would be like nothing happened. But I understand your point of view, and I’ll think about it. By the way, I was considering an approach similar to the Alarmy app: when the app is killed, and the alarm time is reached, they send multiple notifications—one every 5 seconds or so—with sounds, simulating an alarm. It’s not a perfect solution because if the device is in Do Not Disturb or silent mode, the user may not notice.
I just released version 4.0.9
with the following features:
volumeEnforced
(some users requested this; if set to true, the alarm volume can’t be changed while it rings).I believe I can close this issue now. Don’t hesitate to reopen it or create a new one if necessary. Thanks for you help !
Alarm plugin version 4.0.6
I've encountered an issue on iOS where the stop button is not available when the alarm goes off in the notification. As a result, the alarm continues to ring indefinitely unless the app is stopped or cleared from the task manager.
Device info tested on iPhone 16 with iOS 18