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

Reschedule alarms on android device reboot #186

Closed singhcreations closed 1 month ago

singhcreations commented 7 months ago

Alarm plugin latest version

whenever phone is switch off then there is no alarm on alarm time we have to open the alarm app again and again doing the process

gdelataillade commented 7 months ago

Hi @singhcreations

What you need is to automatically reschedule the alarms on device reboot ?

singhcreations commented 7 months ago

default alarm apps didn't effect after device reboot or after switch off then switch on it works again like before but here in this we can't able to get alarm after reboot.

On Mon, 22 Apr, 2024, 2:50 pm Gautier de Lataillade, < @.***> wrote:

Hi @singhcreations https://github.com/singhcreations

What you need is to automatically reschedule the alarms on device reboot ?

— Reply to this email directly, view it on GitHub https://github.com/gdelataillade/alarm/issues/186#issuecomment-2068905526, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYZUNHLEFCIGLIMX5WW4ZJ3Y6TI7NAVCNFSM6AAAAABGQ2JQLOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRYHEYDKNJSGY . You are receiving this because you were mentioned.Message ID: @.***>

AhsanSarwar45 commented 6 months ago

You can use this package to run dart code on device boot: flutter_boot_receiver. You can call the code which schedules alarms in the callback function. I created this package for this exact issue in my clock app.

gdelataillade commented 1 month ago

This feature has been added to alarm version 4.x.x.

jys324 commented 1 month ago

Is this feature really working? The alarm doesn't sound after reboot. My version is 4.0.6.

gdelataillade commented 1 month ago

Please provide your android version.

jys324 commented 1 month ago

phone: Galaxy Note 10, android version: 12, phone2: Galaxy S22, android version: 14. In my case, neither device worked.

gdelataillade commented 1 month ago

Did you add this permission in your manifest ?

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

Make sure you followed the installation steps.

jys324 commented 1 month ago

I already did that. but in my case, After downloading the package, I changed the version of Flutter shared preferences to 2.2.3 to match my dart version. I confirmed that even if I change the version, it saves well in Flutter. Do you think there's a chance that Kotlin won't be able to retrieve the saved value because of this?

gdelataillade commented 1 month ago

I have no idea. Could be possible. Can't you upgrade your dart version ?

Also, depending on the device performance, alarms can take a couple of minutes to be rescheduled after a device reboot.

jys324 commented 1 month ago

I tried many times to upgrade the dart version, but failed. I don't think that's the case for me..

I will try harder first. Thank you for your kind reply!

gdelataillade commented 1 month ago

Good luck !

jys324 commented 1 month ago

I found a solution! I created a BootReceiver.kt file next to kotlin mainActivity.kt in my app folder and added this code and it worked.

class BootReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { if (intent.action == "android.intent.action.BOOT_COMPLETED") {} } }

I think it would be a good idea to notify others as they may experience this same problem.

gdelataillade commented 1 month ago

@jys324 it shouldn't be necessary... the alarm plugin has its own BootReceiver.

singhcreations commented 3 weeks ago

please make feature of repetition of alarm daily because your custom daily alarm code is not always workable

On Mon, 21 Oct, 2024, 2:30 am Gautier de Lataillade, < @.***> wrote:

@jys324 https://github.com/jys324 it shouldn't be necessary... the alarm plugin has its own BootReceiver.

— Reply to this email directly, view it on GitHub https://github.com/gdelataillade/alarm/issues/186#issuecomment-2425220149, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYZUNHLUGGXTC23E47O75Y3Z4QKVNAVCNFSM6AAAAABGQ2JQLOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRVGIZDAMJUHE . You are receiving this because you were mentioned.Message ID: @.***>