Closed steveng15 closed 7 months ago
Hi @steveng15
Make sure to follow the installation steps in the README. Also, have you asked for notification permission ? Do you have any error logs to share ?
I have followed the README. How to request notification permission?
This is my buildAlarm dan saveAlarm code
i dont have error logs on my code. If i'm using android and i killed the app, alarm only ringing but don't show notification. But if i'm using simulator ios, alarm showing notification.
Hi @steveng15
Your code looks good to me.
To make sure the notification permission was allowed you can check in your app' settings in the iOS/Android Settings app. If you need to ask the user to give the notification permission you can take a look at the example code. You should use the https://pub.dev/packages/permission_handler package.
Thanks for helping me. It's works.
notification permission on my phone is not allowed and then i'm allow this permission. I will adding permission handler for user to allow this notification permission. Thanks a lot @gdelataillade
Hi @gdelataillade
Sry, i have 1 question. In the notification that appears, where can I change the text that appears in the notification? I tried to add await Alarm.setNotificationOnAppKillContent(title, body) in the ring.dart file, providing static text, but it still doesn't change. The notification still uses the title and body from the existing properties.
Hi @steveng15
For the notification that shows when app is killed, make sure to call Alarm.setNotificationOnAppKillConrent
before calling Alarm.set
. I recommend to call this just after calling await Alarm.init
.
Let me know if it works for you.
HI @steveng15 I have same issue in when app killed then alarm not ring even i follow all steps which mention in package setup like all permission, add service in AndroidManifest.xml file
For now I have check in android device only
I used latest alarm package version
alarm: ^3.0.14
Note, I used Notification & Schedule Exact Alarm Permission is also Granted compileSdkVersion 34 targetSdkVersion 34 multiDexEnabled true
Added in main.dart file await Alarm.init(showDebugLogs: true);
Hi @gdelataillade I download your repo example code but still in same not ring alarm after app killed Please help me what I'm doing wrong
Thanks @gdelataillade @steveng15 in Advance.
Hi @pnilkanth12
Have you granted the notification permission ?
If yes, please also try to:
Hi @gdelataillade Yes I have given permission for Notification & Schedule Exact Alarm Permission and in my mobile battery optimisation is disable but still not working
Here app info screenshot may be you got more idea
in app foreground & background it's work perfect but when app killed then not work even not getting notification
Hi @pnilkanth12
That's really weird. Could you try with another device ? This way we could know if the issue comes from the device or not.
Hi @gdelataillade Thanks I have xiaomi phone in not work but after I check as you said in different device is Samsung so in Samsung device work
but in Samsung device app not open when alarm ring but only notification getting and notification click to open app alarm screen
Thanks
@pnilkanth12 so you have the ring issue only with the xiaomi phone ?
Hi @gdelataillade in Xiaomi phone nothing work when app state is killed and in Samsung phone when app killed then show only notification. not open app like when app foreground or background and alarm ring then show alarm screen open for stop and snooze alarm but not behave this in Samsung phone
Hi @pnilkanth12
I don't have a Xiaomi device to test, but after doing some research I read about the "Autostart" permission in Xiaomi settings. Is that a thing ? What if you enable it ? Furthermore, I think there are more security settings that you could check. There is a Security app ? About Samsung, I think there is a "Appear on top" permission right ?
Please try to play with all these settings and let me know if you find something.
Hi @gdelataillade Thanks a lot After enable "Autostart" permission it's working fine
Hi @gdelataillade Thanks a lot After enable "Autostart" permission it's working fine
Good to know. I found this plugin that you could implement in your app to suggest your users to enable the Autostart
permission:
https://pub.dev/packages/auto_start_flutter
I will also mention it in the plugin's readme.
Yeah that's great @gdelataillade
I have one suggestion to add one more map variable in AlarmSettings model class You can see in my code screenshot that for now I made a little change in this package code and added an extra variable, so suppose if there is any other information you would like to add, like an alarm note, etc., the developer can add in this variable and the alarm time they can get.
@pnilkanth12 what is the purpose of passing an "information" to the alarm ? What is the use case ?
Hi @steveng15
For the notification that shows when app is killed, make sure to call
Alarm.setNotificationOnAppKillConrent
before callingAlarm.set
. I recommend to call this just after calling awaitAlarm.init
. Let me know if it works for you.
sorry for replying,
For Alarm.init()
I stored it in main.dart
This is my main.dart code:
Where do I put Alarm.setNotificationOnAppKillContent? Is it when the alarm goes off which is on ring.dart
I try use static data for Alarm.setNotificationOnAppKillContent
and it's not work.
Alarm plugin version Latest version 3.0.14
Describe the bug The alarm does not display notifications when the application is closed in android. However, it still sounds. If i'm using simulator ios, alarm showing notifications when the app is closed (killed). I have tried adding
enableNotificationOnKill
, but it has no effect. Can you help me figure out where the problem might be?Is there any code that I need to show you?
Expected behavior Alarm show notification on android.
Device info