rafaelsetragni / awesome_notifications

A complete solution to create Local Notifications and Push Notifications, throught Firebase or another services, using Flutter.
https://discord.awesome-notifications.carda.me
Apache License 2.0
759 stars 328 forks source link

swipe to dismiss notification. #950

Closed vishnuvardhankota closed 1 month ago

vishnuvardhankota commented 4 months ago

In the below code even i use locked: true and autoDismissible: false the notification is still dismissing if I swipe it. please fix the issue. and there is no way to recognize that that notification is dismissed by swiping without any actions.

await AwesomeNotifications().createNotification( content: NotificationContent( id: notificationId, channelKey: 'amigos_channel_id_calls', title: 'Incoming call from $userName', body: 'Tap Answer or Decline', payload: { "sender": data['sender'], }, locked: true, autoDismissible: false, notificationLayout: NotificationLayout.Default), actionButtons: [ NotificationActionButton(key: 'ANSWER', label: 'Answer'), NotificationActionButton(key: 'DECLINE', label: 'Decline'), ]);

sagnik-sanyal commented 4 months ago

Hi there are you facing this on Android 14 device with call style notifications ?

Nejc-Podlogar commented 3 months ago

Hi @sagnik-sanyal

We are facing the same problem as @vishnuvardhankota and to answer your question. Yes the problem is on the Android version 14.

Our code is:

Notification creation:

Future<void> createLocalInstantNotification(
    BuildContext context, Measurement measurement) async {
  await awesomeNotifications.createNotification(
      content: NotificationContent(
        id: 1,
        channelKey: 'basic_channel',
        title: S.of(context).addTheMeasurementText,
        body: S.of(context).measurementType(measurement.measurementType),
        autoDismissible: false,
        category: NotificationCategory.Alarm,
        wakeUpScreen: true,
        criticalAlert: true,
        locked: true,
      ),
      actionButtons: [
        NotificationActionButton(
            key: 'addMeasurement', label: S.of(context).titleAddMeasurement)
      ]
  );

For channel creation:

Future<void> configuration() async {
  await awesomeNotifications.initialize(
      null,
      [
        NotificationChannel(
            channelKey: 'basic_channel',
            channelName: 'Basic Notification',
            defaultColor: Colors.teal,
            importance: NotificationImportance.High,
            channelShowBadge: true,
            channelDescription: 'Basic Instant Notification',
            locked: true
        ),
      ],
      debug: true
  );
}
sagnik-sanyal commented 3 months ago

Hi @Nejc-Podlogar It seems this occurs due to the behaviour change on Android 14 mentioned here https://developer.android.com/about/versions/14/behavior-changes-all#non-dismissable-notifications

swarupbc commented 3 months ago

Hi @sagnik-sanyal

Also, this new behavior doesn't apply to notifications in the following use cases:

CallStyle notifications Device policy controller (DPC) and supporting packages for enterprise Media notifications The default Search Selector package

is there any way I can use the CallStyle/Ongoing call notification, so my notification remain non-dismissible? like whatsapp ongoing call, I'm trying to achieve the same.

github-actions[bot] commented 1 month ago

This issue was automatically closed due inactivity, but can be reopened at any time.