I am developing flutter application using awesome notification. I want to redirect to notification page when notification is clicked.
Initialize main.dart notification:
AwesomeNotifications().initialize(
'resource://drawable/ic_stat_ida',
[
NotificationChannel(
channelKey: 'notification_channel',
channelName: 'Normal Notifications',
channelDescription: 'Notification channel for normal notifications',
defaultColor: Color(0xFFffa473),
ledColor: Colors.white,
importance: NotificationImportance.High,
playSound: true,
enableLights: true,
enableVibration: true,
channelShowBadge: false)
],
debug: true);
If the application is closed, I do the following on splashscreen:
void initState() {
super.initState();
AwesomeNotifications().actionStream.listen((receivedAction) {
var payload = receivedAction.payload;
print(payload);
result = true;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => OrganizerNotificationScreen(
taskId: receivedAction.id.toString(),
taskBody: receivedAction.body,
),
));
});
}
This is succesful. But I want to redirect when the notification is clicked on any page while the application is open.
void listenOrganizerNotification(context) {
AwesomeNotifications()
.actionStream
.listen((ReceivedNotification receivedNotification) {
print('event received!');
print(receivedNotification.toMap().toString());
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => OrganizerNotificationScreen(
taskId: receivedNotification.id.toString(),
taskBody: receivedNotification.body,
),
));
});
}
Where should I write listen and redirect function?