title: Flutter - Automatically start application on Firebase FCM Notification Received
body: <p>I'm developing an application, related to Child Security, in Flutter.</p>
  <p>A parent can request the child's application to send an <strong>Image</strong> or a <strong>15 seconds Audio</strong>.</p>
  <p><strong>FCM</strong> is implemented and perfectly working fine <strong>when the application is running or in the background</strong>. When a notification received on Child's mobile application, the application moves to the relevant screen and performs the task.</p>
  <p>But when the application is closed/terminated, it's not working. The notification is received, but the application doesn't start automatically. <strong>I have to click the notification, which I don't want to.</strong></p>
  <p>Can I achieve this, in Flutter? Something like <strong>WhatsApp or Facebook Messenger</strong> call feature?</p>
  <p>What I have tried so far is, calling the <code>main</code> function on a notification received or <code>runApp</code>, but got no success.</p>
  <pre><code>void _firebaseMessagingBackgroundHandler(RemoteMessage message) {
      main();
      &lt;------- and ------&gt;
      runApp(MaterialApp(home: ChildDashboard()));
  }
  
  void main() async {
    WidgetsFlutterBinding.ensureInitialized();
    await Firebase.initializeApp();
    FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
    runApp(MaterialApp(
        debugShowCheckedModeBanner: false,
        home: CustomSplash(
          imagePath: 'assets/images/logo.png',
          backGroundColor: Colors.pink[50],
          animationEffect: 'zoom-in',
          logoSize: 1000,
          home: sendToRelevantScreen(),
          duration: 2500,
          type: CustomSplashType.StaticDuration,
      ),
   ));
  }
  </code></pre>