I need to open the app automatically on receiving a notification message. Is it possible in flutter?
Below is the code for handling the background messages and it works.
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
print('Handling a background message ${message.messageId}');
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
......
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: MyApp()
)
);
What I need is I have a separate page that needs to popup when that particular function is executed (When the app is in background). Can anyone help me out with this! Thanks in advance
In this code the onResume function will help you run the app from background so you can code inside onResume and navigate to your specified screen.