title: how to navigate when click background notification on Flutter?
body: <p>Is it possible to navigate to a specified path when clicking <strong>background</strong> FCM notification?</p>
  <p>I created a <strong>Top-Level</strong> function and add it to the navigator path but its not working, when clicking on a background notification, it just opens the app</p>
  <p><strong>I GUESS I FOUND AN ISSUE</strong></p>
  <blockquote>
  <p>Now, I changed <code>fcm</code> configuration from <code>home page</code> to <code>splash screen</code>.
  The foreground doesn't navigate to the page, I think its because the Splash Screen is no longer available. When I click on the notification message, it just opens the app.</p>
  </blockquote>
  <p><strong>FCM Configuration</strong></p>
  <pre><code>onBackgroundMessage: backgroundMessageHandler
  </code></pre>
  <p><strong>Top-Level</strong> function</p>
  <pre><code>Future&lt;dynamic&gt; backgroundMessageHandler(Map&lt;String, dynamic&gt; message) {
    if (message.containsKey('data')) {
      getIt&lt;NavigationService&gt;().navigateTo('/${message['data']['screen']}');
    }
  }
  </code></pre>
  <p><strong>Payload</strong></p>
  <pre><code>const payload: admin.messaging.MessagingPayload = {
                  notification:{
                      title: `New Enquiry`,
                      body:`${customerName} published to ${subName}`,
                      badge: '1',
                      sound: 'default'
                  },
                  data: {
                      click_action: `FLUTTER_NOTIFICATION_CLICK`,
                      sound: `default`,
                      status: `chat`,
                      screen: `homePage`
                    }
              }
  </code></pre>
  <p><strong>main.dart</strong></p>
  <pre><code>GetIt getIt = GetIt.instance;
  
  void main() {
    setupLocator();
      runApp(MyApp());
  }
  </code></pre>
  <p><strong>MaterialApp</strong></p>
  <pre><code> return MaterialApp(
        navigatorKey: NavigationService().navigatorKey,
        onGenerateRoute: Router.generateRoute,
      );
  </code></pre>
  <p><strong>NavigationService</strong> and <strong>setupLocator</strong></p>
  <pre><code>class NavigationService {
    final GlobalKey&lt;NavigatorState&gt; navigatorKey =
        new GlobalKey&lt;NavigatorState&gt;();
  
    Future&lt;dynamic&gt; navigateTo(String routeName) {
      return navigatorKey.currentState.pushNamed(routeName);
    }
  }
  
  void setupLocator() {
    getIt.registerLazySingleton(() =&gt; NavigationService());
  }
  </code></pre>