Flutter FCM push notification - Foreground Notification tap event
849
You can try this, hope its help you:
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print('Got a message whilst in the foreground!');
print('Message data: ${message.data}');
if (message.notification != null) {
print('Message also contained a notification: ${message.notification}');
}
});
I copy that code from the Flutter Fire documentation, I will put the link here https://firebase.flutter.dev/docs/messaging/usage
Author by
Ajay Kumar
Updated on January 01, 2023Comments
-
Ajay Kumar over 1 year
Am using firebase_messaging and flutter_local_notifications packages, Currently am able to get the notification data when the user tap the notification when the app is in the background. How can i listen to the tap event when the app is in the foreground.
-
Ajay Kumar over 2 yearsHi @Ananda thanks for the answer but this event is triggered when a notification is received but i need it when the user tap the notification.
-
Ananda Pramono over 2 yearsOh sorry about it. You can try this, maybe it will help in some ways. stackoverflow.com/questions/57650892/…