Santosh Kumar
Santosh Kumar

Reputation: 11

Open a screen when firebase notification received in flutter while app is background or terminated

want to create a screen that launch when a firebase notification is received while the app is in the background or terminated in flutter (like package callKeep ).please anyone help me create that.

Upvotes: 1

Views: 585

Answers (1)

Meet Shah
Meet Shah

Reputation: 82

You just need to handle its background handler method it will works.You need to initialize this method in main() method.

Future<void> backgroundHandler(RemoteMessage message) async {
  debugPrint(message.toString());
  debugPrint(message.data.toString());
  debugPrint(message.notification!.title);
}
 FirebaseMessaging.onBackgroundMessage(backgroundHandler);

Upvotes: -2

Related Questions