Does anyone have any code that, when receiving a Push Notification and clicking on it, navigates to a specific page? I am using this code, where there is a lot of action inside except navigation.

Custom Code


Does anyone have any code that, when receiving a Push Notification and clicking on it, navigates to a specific page? I am using this code, where there is a lot of action inside except navigation.

// Automatic FlutterFlow imports
import '/backend/schema/structs/index.dart';
import '/actions/actions.dart' as action_blocks;
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:awesome_notifications/awesome_notifications.dart';

Future initializeMessaging() async {
  // Add your function code here!

  await Firebase.initializeApp();

  FirebaseMessaging.instance.requestPermission().then((settings) {
    if (settings.authorizationStatus == AuthorizationStatus.authorized) {
      FirebaseMessaging.instance.getToken().then((token) {
        // Assuming FFAppState is a singleton or has been instantiated elsewhere appropriately.
        // Update the FCM token in your app's state.
        FFAppState().registrationIds = token ?? 'No token';
      });
    } else {
      // Handle the case where permission is not granted.
      FFAppState().registrationIds = 'No token';
    }
  });

  // Initialize our local notifications
  await AwesomeNotifications().initialize(
      null, //'resource://drawable/res_app_icon',//
      [
        NotificationChannel(
            channelKey: 'alerts',
            channelName: 'Alerts',
            channelDescription: 'Notification tests as alerts',
            playSound: true,
            onlyAlertOnce: true,
            groupAlertBehavior: GroupAlertBehavior.Children,
            importance: NotificationImportance.High,
            defaultPrivacy: NotificationPrivacy.Private,
            defaultColor: Colors.deepPurple,
            ledColor: Colors.deepPurple)
      ],
      debug: true);

  FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
    // Assuming you have a method to display notifications or update UI:
    // showNotification(message.notification?.title, message.notification?.body);
    print('received message 1: ${message.notification?.title}');

    await AwesomeNotifications().createNotification(
        content: NotificationContent(
            id: -1, // -1 is replaced by a random number
            channelKey: 'alerts',
            title: message.notification?.title ?? 'No title',
            body: message.notification?.body ??
                'No body', // 'Hello! How are you?',
            // bigPicture: 'https://storage.googleapis.com/cms-storage-bucket/d406c736e7c4c57f5f61.png',
            // largeIcon: 'https://storage.googleapis.com/cms-storage-bucket/0dbfcc7a59cd1cf16282.png',
            //'asset://assets/images/balloons-in-sky.jpg',
            // notificationLayout: NotificationLayout.BigPicture,
            payload: {'notificationId': '1234567890'}),
        actionButtons: [
          NotificationActionButton(
              key: 'DISMISS',
              label: 'Fechar',
              actionType: ActionType.DismissAction,
              isDangerousOption: true),
        ]);
  });
}


What have you tried so far?
// Automatic FlutterFlow imports
import '/backend/schema/structs/index.dart';
import '/actions/actions.dart' as action_blocks;
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:awesome_notifications/awesome_notifications.dart';

Future initializeMessaging() async {
  // Add your function code here!

  await Firebase.initializeApp();

  FirebaseMessaging.instance.requestPermission().then((settings) {
    if (settings.authorizationStatus == AuthorizationStatus.authorized) {
      FirebaseMessaging.instance.getToken().then((token) {
        // Assuming FFAppState is a singleton or has been instantiated elsewhere appropriately.
        // Update the FCM token in your app's state.
        FFAppState().registrationIds = token ?? 'No token';
      });
    } else {
      // Handle the case where permission is not granted.
      FFAppState().registrationIds = 'No token';
    }
  });

  // Initialize our local notifications
  await AwesomeNotifications().initialize(
      null, //'resource://drawable/res_app_icon',//
      [
        NotificationChannel(
            channelKey: 'alerts',
            channelName: 'Alerts',
            channelDescription: 'Notification tests as alerts',
            playSound: true,
            onlyAlertOnce: true,
            groupAlertBehavior: GroupAlertBehavior.Children,
            importance: NotificationImportance.High,
            defaultPrivacy: NotificationPrivacy.Private,
            defaultColor: Colors.deepPurple,
            ledColor: Colors.deepPurple)
      ],
      debug: true);

  FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
    // Assuming you have a method to display notifications or update UI:
    // showNotification(message.notification?.title, message.notification?.body);
    print('received message 1: ${message.notification?.title}');

    await AwesomeNotifications().createNotification(
        content: NotificationContent(
            id: -1, // -1 is replaced by a random number
            channelKey: 'alerts',
            title: message.notification?.title ?? 'No title',
            body: message.notification?.body ??
                'No body', // 'Hello! How are you?',
            // bigPicture: 'https://storage.googleapis.com/cms-storage-bucket/d406c736e7c4c57f5f61.png',
            // largeIcon: 'https://storage.googleapis.com/cms-storage-bucket/0dbfcc7a59cd1cf16282.png',
            //'asset://assets/images/balloons-in-sky.jpg',
            // notificationLayout: NotificationLayout.BigPicture,
            payload: {'notificationId': '1234567890'}),
        actionButtons: [
          NotificationActionButton(
              key: 'DISMISS',
              label: 'Fechar',
              actionType: ActionType.DismissAction,
              isDangerousOption: true),
        ]);
  });
}
Did you check FlutterFlow's Documentation for this topic?
No