· Figuring it out as I go

Custom navigation with push notifications

I have a project where I am implementing custom push notifications. I wrote a cloud function modeled after the one that flutterflow deploys when you enable push notifications. However, I am not sure how flutterflow implements the initialPageName functionality in the push notification. My message payload has the property, but I am not sure how I am supposed to handle it.

This is the current message payload I am sending (I haven't implemented the sound property yet) and I am sending it as a multicast message via the FCM admin package.

    // Construct FCM message payload
    const message: admin.messaging.MulticastMessage  = {
      notification: {
        title,
        body,
      },
      tokens: fcmTokens,
      data:{
        initialPageName,
        parameterData: paramString
        },
        android: {

        },
        apns:{
            payload:{
                aps:{

                }
            }
        }
    };

    console.log('Attempting to send message: ', message);
    await admin.messaging().sendEachForMulticast(message);

this is based off of the implementation that flutterflow deploys below:

    const tokensBatch = tokensArr.slice(i, Math.min(i + 500, tokensArr.length));
    const messages = {
      notification: {
        title,
        body,
        ...(imageUrl && { imageUrl: imageUrl }),
      },
      data: {
        initialPageName,
        parameterData
      },
      android: {
        notification: {
          ...(sound && { sound: sound }),
        },
      },
      apns: {
        payload: {
          aps: {
            ...(sound && { sound: sound }),
          },
        },
      },
      tokens: tokensBatch,
    };
    messageBatches.push(messages);

My question is how do I get the application to use the initialPageName property to navigate to on open?

1
5 replies