flutter_local_notifications icon indicating copy to clipboard operation
flutter_local_notifications copied to clipboard

onDidReceiveNotificationResponse function not working when clicking on a notification to redirect to a specific screen in app

Open benj12 opened this issue 6 months ago • 4 comments

Describe the bug

When clicking on a test notification it is supposed to link to a different screen but when clicking on a notification it doesn't do anything. It seems like this is a common issue with the flutter_local_notifications package.

To Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

How do you fix this issue?

Sample code to reproduce the problem

benj12 avatar May 29 '25 04:05 benj12

Same issue

Henggg22 avatar May 30 '25 11:05 Henggg22

thisi is very big problem... please resolve this one.

my version Flutter 3.29.2 • channel stable • https://github.com/flutter/flutter.git Framework • revision c236373904 (3 months ago) • 2025-03-13 16:17:06 -0400 Engine • revision 18b71d647a Tools • Dart 3.7.2 • DevTools 2.42.3 flutter_local_notifications: ^18.0.1

shun0921 avatar Jun 03 '25 08:06 shun0921

The logic to go to different screen is up to apps to implement. Whilst the example app is using the old navigator APIs, it shows that it is working. You'll need to provide a link to repository hosting a minimal app that shows that there's a problem with the plugin around this

MaikuB avatar Jun 04 '25 01:06 MaikuB

Describe the bug

I'm trying to use the onDidReceiveNotificationResponse when clicking on a notification to redirect to a specific screen in app. In specific test case, I'm trying to redirect to test1.dart. When I click on the notification however, it doesn't link to test1.dart. Instead all that happens is that it opens the app but doesn't go to the specific page I want it to go to (i.e. test1.dart).

To Reproduce

  1. Clone the repository
  2. Checkout branch cc36282
  3. Run the app by running flutter run (make sure you have an iOS Xcode simulator for iPhone with iOS 18.1 installed.
  4. Once app is loaded, scroll down to the very bottom and click on send virtue notification.
  5. I'm calling showInstantNotification in services/scheduleNotifications.dart in my home.dart file. The showInstantNotification is at the very bottom of my code in my home.dart that will send a virtue notification right away.

Expected behavior

The expected behavior is that it would send the virtue notification right away and when clicking on it, it should link to test1.dart.

Sample code to reproduce the problem go to https://www.github.com/benj12/testapp to fork this repository. For the showInstantNotification function, go to https://github.com/benj12/testapp/blob/master/lib/services/schedule_notifications.dart#L407-L444 .

benj12 avatar Jun 04 '25 03:06 benj12

I figured out how to fix the issue. Clone the sample app and compare the code with your code for main.dart as well as the other files. If there are major discrepancies, fix them. This fixed my issue.

benj12 avatar Jun 24 '25 03:06 benj12