Show Room on Tap Notification
When the user taps the notification it should show the correspondent room. For that you need to navigate to the room using the onSelectNotification callback of the flutter local notification plugin.
Tons of problems here to do that
- We are standing on a NotificationsBloc so no Context to use for Navigation.
- Even if you manage to pass the Context (wrong thing to do), it must be a static property to use on onSelectNotification It makes no sense on pass a Context on the constructor and set it as static
- You could make another callback to App, but it is Stateless so.... feels weird to do things on a Stateless Widget
- I believe the correct thing to do is manage the behavior on the Bloc itself. To use Context here you need to assign a GlobalKey to the MaterialApp and use it on the NotificationBloc. The flutter local notification is a life safer here because it has everything to execute a function to do anything you want.
- The onResume and onLaunch functions did not fired. https://pub.dev/packages/firebase_messaging (optional, but recommended) If want to be notified in your app (via onResume and onLaunch, see below) when the user clicks on a notification in the system tray include the following intent-filter within the tag of your android/app/src/main/AndroidManifest.xml
These are the links where I tried to find a clue of how to navigate without a Context
https://stackoverflow.com/questions/48403786/how-to-open-particular-screen-on-clicking-on-push-notification-for-flutter https://stackoverflow.com/questions/54740695/navigator-not-work-in-firebase-messaging-callback-method/54741982 https://medium.com/@nitishk72/flutter-local-notification-1e43a353877b Solution that worked: https://stackoverflow.com/questions/54137420/flutter-local-notification-plugin-navigate-to-specific-screen-when-the-user-ta
Some good stuff I found:
This a way to add buttons to the Notification for example to answer or reject a call https://stackoverflow.com/questions/36067899/android-notification-action-button-click-listener
There is a new version of the flutter local notification, but it does not work the same as the 0.8.4 The Notification does not pop up with the new version, it is present and you can tap on it but it doesn't pop up.
Any improvement or suggestion are welcome