How to open an external URL from FCM Notification for Flutter app (Android and iOS)?

Viewed 184

Is it possible to open a link by clicking on a notification sent by Firebase Cloud Messaging to a Flutter app (Android & iOS) while the app is closed? I am using Legacy HTTP Requests.

1 Answers

it's possible! You need to write listener for background service, it's actually already in the firebase_messaging package. Then you need to write function for launch url from your FCM notification. Learn FLUTTER_NOTIFICATION_CLICK

This is for example:

FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
      print('A new onMessageOpenedApp event was published!');
      currentBottomIndex = 2;
      goHome(context);
    });
Related