Push Notifications

Sending Push Notifications Through Firebase for Developers - Ultimate Push Notification Service Guide

Anjali Arya
March 4, 2024
Learn how to send push notifications using Firebase directly. Understand push notifications service and how it works.
TABLE OF CONTENTS

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:

  1. Part 1 - Getting Started with Web Push Notifications Service Workers
  2. Part 2 - Obtaining User Permissions and Managing Subscriptions for Web Push Notifications
  3. 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:

  1. Sign in to the Firebase Console using your Google account credentials.
  2. 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>.
  3. 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.
  4. 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.
  5. 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.
  6. 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:
Attribute Description Supported? Example
app_version Application build number / version code Yes eq(12)
language User interface locale Yes en_US
os Operating System Yes android, ios
country Country determined by IP address Limited US
region Region derived from IP address Limited CA-ON
city City detected from GPS location No Toronto
latitude Latitudinal coordinate No 43.6532
longitude Longitudinal coordinate No -79.3832
reg_id Registration token assigned during SDK initiation Yes fcm_*:XXXXXXXXXX...
scope Token belonging to a single sender ID Yes _default
source Source identifier of the installation package No com.example.myapp
firebase Firebase Installation UID No FZ6YRjlUrTgV5oNc....
gmp_id Google Marketing Platform ID No ABCDEFGHIJKLMNOP.....

For example, the following condition targets users who run version 12 of your app and speak English:

        
            {
              "attribute": {
                "app_version": {
                  "_eq": "12"
                },
                "language": {
                  "_eq": "en_US"
                }
              }
            }         
        
    

  1. 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.
  2. 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.

Written by:
Anjali Arya
Product & Analytics, SuprSend
ABOUT THE AUTHOR

What’s a Rich Text element?

The rich text element allows you to create and format headings, paragraphs, blockquotes, images, and video all in one place instead of having to add and format them individually. Just double-click and easily create content.

Static and dynamic content editing

A rich text element can be used with static or dynamic content. For static content, just drop it into any page and begin editing. For dynamic content, add a rich text field to any collection and then connect a rich text element to that field in the settings panel. Voila!

How to customize formatting for each rich text

Headings, paragraphs, blockquotes, figures, images, and figure captions can all be styled after a class is added to the rich text element using the "When inside of" nested selector system.

Implement a powerful stack for your notifications

By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.