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

cancelNotification in AndroidNotificationAction it's not working #2527

Open
mbenci opened this issue Feb 3, 2025 · 3 comments
Open

cancelNotification in AndroidNotificationAction it's not working #2527

mbenci opened this issue Feb 3, 2025 · 3 comments

Comments

@mbenci
Copy link

mbenci commented Feb 3, 2025

Describe the bug
I modified the example file in particular in the text response action "_showNotificationWithTextAction" by adding "cancelNotification: false" in order that the notification remains even following the response.
The effect is that upon clicking on sending the test message a perpetual loader.

flutter_local_notification_text_input_bug.mp4

To Reproduce
Change the method _showNotificationWithTextAction in the example code like this

Future<void> _showNotificationWithTextAction() async {
    const AndroidNotificationDetails androidNotificationDetails =
        AndroidNotificationDetails(
      'your channel id',
      'your channel name',
      channelDescription: 'your channel description',
      importance: Importance.max,
      priority: Priority.high,
      ticker: 'ticker',
      actions: <AndroidNotificationAction>[
        AndroidNotificationAction(
          'text_id_1',
          'Enter Text',
          icon: DrawableResourceAndroidBitmap('food'),
          cancelNotification: false,
          inputs: <AndroidNotificationActionInput>[
            AndroidNotificationActionInput(
              label: 'Enter a message',
            ),
          ],
        ),
      ],
    );

Launch the example app --> click on the "Show notification with text action" button --> respond to the notification and send

Expected behavior
The expected behavior is that the message is sent and the notification remains present

@jayantur13
Copy link

jayantur13 commented Feb 4, 2025

In manifest, you may have forgot to add this -

<receiver 
       android:name="com.dexterous.flutterlocalnotifications.ActionBroadcastReceiver" 
       android:exported="false"/>

From #2152

@mbenci
Copy link
Author

mbenci commented Feb 4, 2025

My manifest is correct, but the manifest in the example is also correct and in fact the behavior is the same.
(https://github.com/MaikuB/flutter_local_notifications/blob/master/flutter_local_notifications/example/android/app/src/main/AndroidManifest.xml)

@MaikuB
Copy link
Owner

MaikuB commented Feb 12, 2025

I tried to reproduce this onn the Android emulator. Yet to try on my Pixel device as I won't get to do so until later but expect to run into same behaviour.

Scenario 1: when cancelNotification is left to the default of true. The notification remains on screen and shows what was entered. I'm not sure if you saw the same behaviour but if you did, it seems to align with what you actually want. There may be a gap in documentation on this specific combination

Screen_recording_20250212_231908.webm

Scenario 2: when I set it to cancelNotification to false as mentioned in the original post, the loader showed up but then disappeared. Based on this, it looks like a device-specific issue and if so, not much else the plugin can do

Screen_recording_20250212_231703.webm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants