I am using flutter_local_notifications: ^15.1.0+1 to show notification using FCM. i was able to handle notification click on foreground and background clicks , But i couldn't find a function which is invoked on notification tap while the app is in terminated state. Any help will be welcomed .
onDidReceiveNotificationResponse is invoked while app is in background or foreground,
Using custom notification with local_notification package,
below is my FCM content
{ "message":{
"token":"token_1",
"data":{
"title":"FCM Message",
"body":"This is an FCM notification message!",
}
}
flutter_local_notificationswill handle incoming message in theforegroundnotification. because theFirebase Android SDKwill block displaying any FCM notification no matter what Notification Channel has been set.read here for detail: https://firebase.flutter.dev/docs/messaging/notifications#application-in-foreground
while on
teminatedstate, no need to use local notification. if you still useflutter_local_notificationto handlebackgroundstate, you will receive 2 notifications at the same time.for handling received message read this documentation: https://firebase.google.com/docs/cloud-messaging/flutter/receive
you can call your method here, it will automatically invoked if the notification incomming in the terminated state
but if you need interaction, for example, you want to navigate specific screen when user click the notification in the `terminated state, then read below:
by default, when we click the notification, it will trigger to open the app. based on my project, I use invoke my method on the
splash screenbefore navigate to home screen.splash_screen.dart