Firebase Cloud Messaging (FCM), formerly known as Google Cloud Messaging (GCM), provides developers a free platform to send targeted, real-time push notifications to their mobile app users. With FCM, you can engage and interact with your customers efficiently while keeping track of user engagement metrics.
Before starting, make sure you have completed the setup process described in this Stackoverflow answer "How To Enable Push Notifications in Your App" to enable push notifications in your app using Firebase.
Read more about push notification service workers in this series:
- Part 1 - Getting Started with Web Push Notifications Service Workers
- Part 2 - Obtaining User Permissions and Managing Subscriptions for Web Push Notifications
- Part 3: Crafting Dynamic and Feature-Rich Push Notifications
Key Considerations
When working with FCM, here are some key points to remember:
- The combined total number of characters in the message body and title must not exceed 1,200 characters. However, individual limits still exist: 1024 for the body and 200 for the title.
- Currently, only text notifications are supported. No multimedia files, rich media, or interactive cards are allowed.
- URL links added to the notification payload work exclusively for opening the corresponding app. Deep linking to specific pages or website resources isn't possible.
- FCM supports scheduled notifications, allowing you to specify a delay before delivering messages. Additionally, you may configure the system based on the listener's local timezone or UTC.
Sending Push Notifications Through Firebase Console
Follow the steps outlined below to learn how to create and send push notifications using the Firebase Console:
- Sign in to the Firebase Console using your Google account credentials.
- From the left sidebar, navigate to Cloud Messaging > Compose new message. Alternatively, access the messaging panel by visiting <https://console.firebase.google.com/project/_/notification>.
- Start crafting your notification by entering text in the Notification Text field. Optionally, provide a distinctive tag in the Collapse Key input. Collapsible keys allow grouping similar notifications together, ensuring that older ones get replaced by newer ones upon receipt.
- Customize the appearance of the notification further by adding a title in the Title field, choosing a background color, and selecting a font style. Although Triton Digital apps currently ignore certain properties like android_channel_id, defining them ensures compatibility with various receiving platforms.
- Specify a message type in the Topic dropdown menu. Topics let you categorize messages and subscribe users accordingly. Leave it blank to address all registered devices.
- Define the target audience for your notification by configuring the Filter conditions. Several attributes serve as filters, including app_version and language. Refer to the table below for details about each parameter:
For example, the following condition targets users who run version 12 of your app and speak English:
- Set up the message expiration by specifying a value for Time to Live (TTL). Upon reaching the specified duration, undeliverable messages due to connectivity issues automatically get discarded. When leaving this field empty, the server defaults to 4 weeks.
- Finally, double-check the entire configuration and opt to either preview the message or queue it for immediate dispatch. Should you wish to test the notification first, pick Select recipient and enter the relevant registration tokens. Then, submit the form.
Congratulations! You just learned how to compose and distribute push notifications using the Firebase Console.
Apart from manual composition, you could automate the process through programming interfaces. One popular choice among developers involves leveraging the Firebase Admin SDK for Java.
Monitor User Engagement Metrics
Tracking user interactions enables informed decision-making regarding future campaigns and enhances overall customer experience. Return to the Firebase Console whenever curiosity strikes to view analytics relating to delivered, opened, clicked, and failed messages. Drill deeper by analyzing trends over time, comparing outcomes between segments, and evaluating retention rates.
Wrapping Up
Push notifications play a crucial role in fostering meaningful connections with end-users, empowering businesses to share pertinent updates, nurture loyalty, and drive growth. Leveraging Firebase Cloud Messaging simplifies management efforts and streamlines processes, ultimately leading to fruitful engagements and increased revenue streams. Embrace this technology and watch your brand ascend to greater heights.