Learn how to integrate Firebase Cloud Messaging with Novu and send notifications to Flutter apps
lib/main.dart
file in your Flutter app and replace everything with the code below:
The Request permission code block
Registering and obtaining the FCM token for the device
getToken()
returns the registration token for the app instance on the device.The foreground message handler
The background message handler
Running the app to build on my device
Notification Permission Prompt
Flutter app running waiting to receive push notifications
Engage
section and click on Messaging
.
Create your first campaign
and select Firebase Notification messages
.
Notification title
and the Nabigateotification text
, and click on Send test message
.
Yaay! Push Notification from FCM on my device
Integrations Store
. Click on Add a provider
.
Service accounts
tab.Generate new private key
, then confirm by clicking Generate key
.Generate key
to download the JSON file.Service Account
field of the FCM provider in the Integration store on Novu’s web dashboard.{{handlebars}}
variables for personalization.
This ensures consistent platform notifications and allows dynamic adjustments for individual subscribers, scenarios, and use cases.
Navigate to 'Workflows' tab and click on 'Blank Workflow'
Add (Drag & Drop) the Push channel node to the workflow
Click on the node, and start to modify the content. Add a title and content. Once you are done, click on 'Update'
Subscribers
section of the Novu dashboard.
Create a subscriber
Grab the FCM device token from your Editor log
Add Device Tokens to Subscriber by Updating Subscriber Credentials
trigger identifier
as the name in the API request below:
Add Push title and content
Trigger Workflow
Push Notification Received on the Device
title
and the body
to {{title}}
and {{body}}
.
That way, we could insert values through the payload of the API call.payload
object to the API call.trigger identifier
as the name in the API request below:
Push Notification received on device from Novu via FCM
Notification
and Data
messages. We have handled sending notification messages. Let’s handle data messages.
Data messages contain user-defined custom key-value pairs. The information is encapsulated in the data
key. The app can do whatever it pleases with the data once it’s received by the device.
Via the Trigger API call
Push & Data Notification received on device in the foreground from Novu via FCM
10
.
10
to send the notification immediately.5
to send the notification based on power considerations on the user’s device.1
to prioritize the device’s power considerations over all other factors for delivery and prevent awakening the device.high
or normal
for the priority of the notification message.