Trigger Push Notification Action
Using this action, you can trigger the push notification when an event occurs in your app. For example, sending the push notification to the post creator when someone comments on a post.
Trigger push notification on button press
Before you add the action to trigger a push notification, you'll need to have the document reference of the user to whom you would like to send the notification. Learn how to retrieve a document reference of the user.
Go to your project page on FlutterFlow and follow the steps below to define the Action to any widget.
- Select the Widget (e.g. Button) on which you want to define the action.
- Select Actions from the Properties panel (the right menu), and click Open. This will open an Action flow Editor in a new popup window.
- Click on the + Add Action.
- On the right side, search and select the Trigger Push Notification action.
- To set who should receive the push notification, set the Audience to Single Recipient or Multiple Recipient.
- If you want to send a notification to a single user, set it to Single Recipient. For example, sending a notification only to the group creator when someone joins the group.
- If you want to send a notification to multiple users, set it to Multiple Recipient. For example, sending a notification to all group members when someone joins the group.
- Set the Source of user document reference (e.g. local state variable or Firestore document).
- Further options are available based on the selected source.
- To set the specific notification title text, open the Notification Title,
- Keep the Value Source to Specific Value, and set the Value to any text such as New comment.
- To set the notification body from a variable, open the Notification Text,
- Set the Value Source to From Variable.
- Set the Source to Widget State.
- Set the Available Options to the widget name which contains the message.
- Set the Default Value if you wish to. This will be displayed if there is an empty message.
- Open the Notification Image section to set the image that you want to appear in the notification. (Optional)
- Turn on the Deliver with Sound if you want to send a notification with the user's default sound/vibration.
- To set which page to open when a user taps the notification, set the Initial Page to the page you would like to open. You can also pass on the parameters if page requests.
Defining Trigger Push Notification