onDidReceiveNotificationResponse function not working when clicking on a notification to redirect to a specific screen in app
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
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior
How do you fix this issue?
Sample code to reproduce the problem
Same issue
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
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
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
- Clone the repository
- Checkout branch cc36282
- Run the app by running flutter run (make sure you have an iOS Xcode simulator for iPhone with iOS 18.1 installed.
- Once app is loaded, scroll down to the very bottom and click on send virtue notification.
- 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 .
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.