-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make alarm periodic #47
Comments
Hi! Thanks for your interest in the package. Yes, this is a feature that could be added. I'll add it when I find the time to do it. I'll let you know. |
I don't think it should be the libraries responsibility. Normally, when get a callback on in our app regarding our alarm went off, we can register the new one again. |
I agree with you @meliksahcakirr, it would make more sense. @moosalim what do you think ? |
@gdelataillade I agree, this is good idea, @meliksahcakirr thanks for the suggestion |
Awesome. I'll close the issue then. Don't hesitate to open another one if you have any other question. |
Can't agree with the conclusion you guys reached for this feature. What if the user didn't open the app when the alarm went off? |
I see. I can make the Android alarm periodic but for the iOS part I don't know if there is a way to execute native code in the background periodically. I'll take a close look at it when I find some time. Feel free to help if you want. |
In summary, while periodic alarms can be implemented on Android, this is not feasible for iOS. To maintain consistency between both platforms, I will not be adding this feature to the package (except if I found a solution). As an alternative, you could store the scheduled days for alarms and reset them for the upcoming week each time the app is launched. |
i think there should be a work around for iOS or what is the problem why is not feasible on iOS if i may ask.. |
Hi @gbbest15 Thank you for your question. Indeed, I am already using background fetch in the application, but the issue lies in the fact that iOS does not provide an API to automatically repeat alarms. This would mean that I would have to manually set alarms for every Monday, for instance, but for what duration? The entire year? That seems impractical. Additionally, it's important to note that the longer a task remains active in background fetch, the higher the chance that iOS will terminate it. Therefore, it’s better to regularly reschedule these tasks to ensure they function properly. If you have any ideas on how to circumvent this limitation or improve this functionality, I would be delighted to hear them. Also, feel free to ask any other questions you might have. |
okay, now i think i understand, i will also make some research here if i can get somethings... but right now is to trigger it with my backend base on my thinking now.. i will see make research on this.. |
Can someone show me the code on how to allow users to repeat alarms daily? |
Hey the package is good for some things but there are a few things that should be in the package.
or could you suggest any other way of doing it in flutter with the current package status |
Making alarms periodical in the plugin with the workaround is not the priority at the moment. If you need to make alarms periodical, the workaround to add to your app is: Every time the user opens the app, you need to schedule his alarms for the following 7 days. Let me know if you have any question. |
Hi @gdelataillade would you happen to have pseudocode to show this in the example file? |
Hi @deep526 I will write a Github Gist with an example of a periodic alarm implementation when I have some time. I'll keep you updated here. |
@gdelataillade Yes please that would be amazing. I got custom sounds made for alarms and created the alarm, but my users are complaining they can't repeat the alarm and it's also not stoping when users click the notification. |
Hi everyone, Here's a Github Gist I wrote to give you an idea of how to implement periodic alarms in your app: https://gist.github.com/gdelataillade/3dae217917d417c5f367557489133619 Please don't hesitate if you have any question. |
hi @gdelataillade thank you for providing the code for periodic alarms. Unfortunately I'm not an expert in flutter so I was unable to implement this into my code. I tried modifying the edit_alarm.dart file and created the ui to show days of the week selected but it was giving errors, it's requiring me to change code on the package files. Hopefully you'll have this option implemented in the example file so it's easier for us self taught coders to implement lol. Thanks for your help, I'll just remove the alarm feature and continue working on trying to make it periodic for now |
Hi @deep526, what kind of errors do you have ? |
Hi @gdelataillade, there no error message that shows up however, when alarm rings and user is directed to the ring.dart screen and they press stop. Then the alarm is deleted. I believe you said the alarm needs to rebuild every time the app opens up or something. I'm just not sure how the implementation works. This is the code I used to allow users input for repeating: Future setPeriodicAlarms(TimeOfDay time, List selectedDays) async {
} |
Hi @deep526 Make sure to call Alarm.init before executing this function. Please carefully read the Readme if it's not already done. Let me know if you still have issues. |
I saved Alarm.init in main.dart and the function for alarm repetition is in another file. how to call it? |
@steveng15 You should put it in a class like |
hello, mr please help me. |
Hi @arymuhammad As explained in this issue, it's not possible to set a periodical alarm at the moment, so you have to do it manually. Please read the issue for more information. |
there is a solution to make the alarm periodic. you can make the stop button stop the current alarm and start a new alarm after 24 hours, and make another button which kill the alarm. |
Yes, I created a separate button and labeled it "Repeat Tomorrow" to allow users to repeat the alarm at the exact same time next day. It just sets a new alarm 24hrs in the future |
@gdelataillade |
Hi @phamquoctrongnta It is recommended that users launch the app to ensure future alarms are scheduled and active. This serves as a security measure to confirm that alarms are functioning correctly. Additionally, it’s advisable to schedule not only your next alarm but also subsequent ones, especially for periodic alarms. Hope this helps, let me know if you have any questions. |
@gdelataillade |
@phamquoctrongnta honestly I don't know, I would try to have alarms scheduled for the next 2 Fridays and see how it goes. Don't hesitate to share your feedback, it can be valuable for everyone. |
modify the stopAlarm function like this
|
is there any updates on this @gdelataillade ? |
@khaledmurtaja sorry I currently don’t have plans to implement this feature, primarily because it would be Android-only. However, contributions are always welcome if you’d like to work on it. In the meantime, I’ve shared a GitHub Gist that might help you implement periodic alarms in your app: https://gist.github.com/gdelataillade/3dae217917d417c5f367557489133619 Please note that the code in the Gist is outdated, but the underlying idea should still be useful as a starting point. Let me know if you have any questions! |
its not workable at all when we select the alarm at first time then alarm works well when we use this code then it will not workable idk what is the issue |
Hello
Thanks for the plugin, appreciate your effort. The alarm is not periodic, it just ring one time. Whereas I believe it should ring every day on the same time, e.g morning wakup every day. Is this a bug or a feature to be added ?
The text was updated successfully, but these errors were encountered: