gdelataillade / alarm

A Flutter plugin to easily manage alarms on iOS and Android
https://pub.dev/packages/alarm
MIT License
132 stars 86 forks source link

Alarm does not ring when app is killed #95

Closed Inihood1 closed 11 months ago

Inihood1 commented 1 year ago

After building out a release version of my app on Android 11, I set an alarm, gave it about 10 seconds, and then killed the application. I notice the alarm didn't ring. It only works when app is in foreground or background and not when it's killed.

Is this a bug or it's intentional? Can you fix it?

gdelataillade commented 1 year ago

Hi @Inihood1,

It is a technical limitation. I'm not able to ring alarm when app is killed, at least for now. For more information, please take a look at the README.

moosalim commented 1 year ago

I think there is a solution for this issue here: https://jja08111.github.io/flutter/flutter-alarm-app/

gdelataillade commented 1 year ago

Hi @Inihood1 @moosalim

I've noticed that many of you have expressed interest in a particular feature. Acknowledging its importance, I've dedicated time to develop it. Unfortunately, due to certain technical constraints within Flutter, it was not feasible to implement this feature directly. To overcome this, I've shifted the Android alarm functionality to native Kotlin code.

I'm excited to share that the development has culminated in PR #105. You can view the details of this PR here.

This work has led to the release of version 3.0.0-dev.1, which is currently in its testing phase. It is available for download and experimentation at: https://pub.dev/packages/alarm/versions/3.0.0-dev.1.

I'm reaching out to our community for assistance in the testing process. Your input and feedback would be immensely valuable, should you have the time to contribute. The goal is to ensure that when we roll out the stable release of version 3.0.0, it meets all our quality and reliability standards.

Thank you for your continuous support and engagement. Your participation in this testing phase will be instrumental in making this release successful.

gdelataillade commented 1 year ago

Hi @Inihood1 @moosalim

I've noticed that many of you have expressed interest in a particular feature. Acknowledging its importance, I've dedicated time to develop it. Unfortunately, due to certain technical constraints within Flutter, it was not feasible to implement this feature directly. To overcome this, I've shifted the Android alarm functionality to native Kotlin code.

I'm excited to share that the development has culminated in PR #105. You can view the details of this PR here.

This work has led to the release of version 3.0.0-dev.1, which is currently in its testing phase. It is available for download and experimentation at: https://pub.dev/packages/alarm/versions/3.0.0-dev.1.

I'm reaching out to our community for assistance in the testing process. Your input and feedback would be immensely valuable, should you have the time to contribute. The goal is to ensure that when we roll out the stable release of version 3.0.0, it meets all our quality and reliability standards.

Thank you for your continuous support and engagement. Your participation in this testing phase will be instrumental in making this release successful.

Inihood1 commented 1 year ago

Thanks. I'll check it out

Inihood1 commented 1 year ago

I just tried it, I ran the sample folder and its still the same problem. Alarm does not fire when app is killed

Inihood1 commented 1 year ago

I think there is a solution for this issue here: https://jja08111.github.io/flutter/flutter-alarm-app/

I will try it. Thanks

gdelataillade commented 1 year ago

@Inihood1 are you sure you used version 3.0.0-dev.1 ? and on an android device ?

in the example app you should see the package version in the app bar

moosalim commented 1 year ago

@gdelataillade Thanks for your response and appreciate your dedication and time to develop this package.

Inihood1 commented 1 year ago

@Inihood1 are you sure you used version 3.0.0-dev.1 ? and on an android device ?

in the example app you should see the package version in the app bar

Yes I did. I tested it on android 11 and I saw the version code on the appear. Alarm was scheduled successfully but didn't fire up when app was killed.

gdelataillade commented 1 year ago

@Inihood1 that's weird...

Can you try to disable battery optimization in your device settings ? Maybe your device is blocking background processes.

Inihood1 commented 1 year ago

@Inihood1 that's weird...

Can you try to disable battery optimization in your device settings ? Maybe your device is blocking background processes.

Honestly, I dont remember enabling battery optimization but recently I noticed my gmail app does not sync message except I open it. So will try it again on another device

gdelataillade commented 1 year ago

@Inihood1 battery optimization is enabled by default in most cases. It depends on the device manufacturer.

What device do you have btw ?

Inihood1 commented 1 year ago

Tecno spark 7p. I will try it on a samsung

gdelataillade commented 1 year ago

Idk about Tecno spark 7p but Samsung is known to have heavy battery optimizations enable by default. You may have to manually disable them to make sure alarms can ring.

Inihood1 commented 1 year ago

Idk about Tecno spark 7p but Samsung is known to have heavy battery optimizations enable by default. You may have to manually disable them to make sure alarms can ring.

I will try it and get back to you ASAP

hoangan commented 1 year ago

Hi @gdelataillade,

I'm having this error during the build

Error (Xcode): No file or variants found for asset:
packages/alarm/assets/not_blank.mp3.

Could not build the application for the simulator.
Error launching application on iPhone 13 Pro.

Any workaround for this?

Thanks.

gdelataillade commented 1 year ago

Hi @hoangan

Sorry it seems I made a mistake in the release.

In the meantime you can try to delete the plugin's .pubignore, it could resolve the issue.

I'll publish a new release with the fix as soon as possible.

Inihood1 commented 12 months ago

Hi @hoangan

Sorry it seems I made a mistake in the release.

In the meantime you can try to delete the plugin's .pubignore, it could resolve the issue.

I'll publish a new release with the fix as soon as possible. Eagerly awaiting...

Inihood1 commented 12 months ago

There is a bug in the sample folder. I cannot set alarm, the progressbar spins forever. Also, the "Ring now" button crashes the app. How soon can you fix this?

Inihood1 commented 12 months ago

I think there is a solution for this issue here: https://jja08111.github.io/flutter/flutter-alarm-app/

I just tried this, it runs on my samsung galaxy AO3 (Android 13) perfectly even when the app is killed but it doesnt work on my Techno Android 11. I think the device itself have some issues, my mail doesnt sync sometimes until I open the gmail. Background task barely runs on the phone. But this is working, thanks

gdelataillade commented 12 months ago

Hi @Inihood1

Do you have any error logs for the example apps issues ? I'm not able to reproduce them with my OnePlus device. Looks like every android device is managing alarms differently.

I'll definitely take a look at the look you sent, it's in Korean though.

I'll do my best to publish a new dev release by the end of the week. Any help in testing or in research is welcome. Latest dev release is ^3.0.0-dev.4.

gdelataillade commented 11 months ago

Android alarms can ring even if app was terminated in version 3.0.0.

Inihood1 commented 11 months ago

Android alarms can ring even if app was terminated in version 3.0.0.

Yeah, I noticed this too. To stop the alarm, simply sleep the phone. But of course the alarm should stop when app is kill.