getNotificationAppLaunchDetails method

Future<NotificationAppLaunchDetails?> getNotificationAppLaunchDetails()

Returns info on if a notification created from this plugin had been used to launch the application.

An example of how this could be used is to change the initial route of your application when it starts up. If the plugin isn't running on either Android, iOS or macOS then an instance of the NotificationAppLaunchDetails class is returned with didNotificationLaunchApp set to false.

Note that this will return null for applications running on macOS versions older than 10.14. This is because there's currently no mechanism for plugins to receive information on lifecycle events.

Implementation

Future<NotificationAppLaunchDetails?> getNotificationAppLaunchDetails() async {
  if (kIsWeb) {
    return null;
  }
  if (defaultTargetPlatform == TargetPlatform.android) {
    return await resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>()
        ?.getNotificationAppLaunchDetails();
  } else if (defaultTargetPlatform == TargetPlatform.iOS) {
    return await resolvePlatformSpecificImplementation<IOSFlutterLocalNotificationsPlugin>()
        ?.getNotificationAppLaunchDetails();
  } else if (defaultTargetPlatform == TargetPlatform.macOS) {
    return await resolvePlatformSpecificImplementation<MacOSFlutterLocalNotificationsPlugin>()
        ?.getNotificationAppLaunchDetails();
  } else {
    return await FlutterLocalNotificationsPlatform.instance.getNotificationAppLaunchDetails() ??
        const NotificationAppLaunchDetails(false);
  }
}