Skip to content
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

Calling alarm stop does not make the notification disappear from the status bar. #215

Open
synstin opened this issue Jun 11, 2024 · 2 comments
Assignees
Labels
android For Android only bug Something isn't working

Comments

@synstin
Copy link

synstin commented Jun 11, 2024

Alarm plugin version
3.1.4

Describe the bug
Is it correct behavior that calling Alarm.stopAll() makes the notification disappear from the status bar?

Sometimes calling stopAll() doesn't make the notification disappear from the status bar.
So, after debugging, I found a few things.

final hasAlarm = Alarm.hasAlarm(); // false
final getAlarms = Alarm.getAlarms(); // size=0
final checkAlarm = await Alarm.checkAlarm(); // null
final isRinging = await Alarm.isRinging(1); // true

The isRinging variable appears to be true.
However, all notifications have already ended.
Is this a bug?

AlarmSettings(
          id: 1,
          dateTime: DateTime.now().add(Duration(seconds: 5)),
          assetAudioPath: 'assets/sound/test.mp3',
          loopAudio: false,
          vibrate: false,
          notificationTitle: 'test',
          notificationBody: "test",
          enableNotificationOnKill: false,
          androidFullScreenIntent: true,
)

The AlarmSettings currently in use.

**DeviceInfo
This only happens on Android.
Does not occur on IOS.
On Android, stopAll() doesn't seem to stop notifications properly.

**Additional
After further testing,
stop(1) correctly removes notification 1.
But stopAll() doesn't work.

@synstin synstin added the bug Something isn't working label Jun 11, 2024
@gdelataillade
Copy link
Owner

Hi @synstin,

Thanks for the details. It seems there is a difference between stopAll (which relies on persistent storage for alarm info) and isRinging (which checks if an audio player with a specific ID is ringing).

When isRinging returns true but getAlarms returns nothing, is your alarm actually playing audio?

Could you please test this scenario a few more times and share the results? More data will help us identify the issue.

I’ll look into this and keep you updated.

@synstin
Copy link
Author

synstin commented Jun 12, 2024

@gdelataillade
The notification is not actually playing audio.
My audio is a very short ding- sound, less than a second.
I wait a long time and then debug and isRinging comes out as true.

Future<void> stopAndSet() async {
  await Alarm.stopAll();
  await Alarm.set(AlarmSettings(
          id: 1,
          dateTime: DateTime.now().add(Duration(seconds: 5)),
          assetAudioPath: 'assets/sound/test.mp3',
          loopAudio: false,
          vibrate: false,
          notificationTitle: 'test',
          notificationBody: "test",
          enableNotificationOnKill: false,
          androidFullScreenIntent: true,
  ));
}


void run() async {
  await stopAndSet();
  await stopAndSet();
  await stopAndSet();
  await stopAndSet();
  await stopAndSet();
  await stopAndSet();
  Alarm.stopAll();
}

This is the logic that simplified my business.
It seems to happen when deleting/registering multiple alarms in a row.

@gdelataillade gdelataillade added the android For Android only label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android For Android only bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants