local_notifications icon indicating copy to clipboard operation
local_notifications copied to clipboard

Notification not auto dismissing on click

Open ghost opened this issue 6 years ago • 5 comments

notificationId = await LocalNotifications.createNotification(
      title: 'Basic',
      content: 'some basic notification',
      // imageUrl: String
      isOngoing: false,
      onNotificationClick: new NotificationAction(
          actionText: "some action",
          payload: "some payload",
          callback: removeNotify,
      ),
...

void removeNotify(String payload) {
    LocalNotifications.removeNotification(notificationId);
  }

Unable to get notification to disappear when clicked. On my personal phone (running Lollipop) they dismiss automatically. While the AVD I am running is v6 this behavior shouldn't be any different.

ghost avatar Mar 25 '18 19:03 ghost

It's possible there is some difference in the Android APIs for the lower versions. I've only tested on 8.1.0 (personal device) and 7.1.1 (AVD). I'll investigate.

mitchhymel avatar Mar 25 '18 19:03 mitchhymel

Appreciate it!

On Sun, Mar 25, 2018 at 3:30 PM, Mitch Hymel [email protected] wrote:

It's possible there is some difference in the Android APIs for the lower versions. I've only tested on 8.1.0 (personal device) and 7.1.1 (AVD). I'll investigate.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mitchhymel/local_notifications/issues/2#issuecomment-375996552, or mute the thread https://github.com/notifications/unsubscribe-auth/AIIciKAsKAzDtAY0gLgYha6d8HQ90Ll0ks5th_A7gaJpZM4S6Quv .

ghost avatar Mar 25 '18 19:03 ghost

I can't seem to repro the issue. I set up an AVD running 6.0 and that code works fine: the notification is dismissed when clicked. Is it possible the value of notificationId is being changed between when the notification is created and when it is clicked?

I don't see any major changes to Android notifications APIs around 6.0, specifically NotificationManager.cancel() seems unchanged. So I'm not really sure why the behavior would be different between your device and AVD.

mitchhymel avatar Mar 27 '18 03:03 mitchhymel

@rucuriousyet In version 0.0.3, I added the ability to enable/disable extra debug print/logging statements. These may help figure out what's going wrong.

To enable logging:

await LocalNotifications.setLogging(true);

mitchhymel avatar Apr 10 '18 01:04 mitchhymel

Hi! I have this issue too, i'm using samsung galaxy S7, Android 7.0. Please help. Thanks.

Note: The notification id did not changed because it was 0 the whole time. It seems like it was not running through callback function.

devsontx avatar May 31 '18 06:05 devsontx