Reputation: 53
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.
Upvotes: 1
Views: 3078
Reputation: 1009
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
Upvotes: 1