Web push notifications have been around for a long time now. Most of the website and application uses them to better engage their user base. Google defines web push notifications as one of the most effective ways to engage the user base and retain them for a longer period. Here we are going to describe basically how FCM Push notification works?
What are push notifications and how they work to deliver messages in real-time?
Simply, a notification is something that pops up on a device with some message in it. They can be triggered locally by a mobile app with some programmed templates, or can also be sent from a server with both custom and programmed content.
The locally triggered notifications have been around even before web-based triggering was prominent. While the local in-app notifications are limited to the apps, a web push notification is more complexed phenomena. There are three core technologies that make a simple web push notification: Push API, Notification API, and Service Worker API.
Where the push API is responsible for delivering a content relayed remotely through a server, the Notification API handles the pop-up on the screen to alert about a new message being received. Both Push and Notification APIs are managed by the Service Worker API, which manages the programmed actions and relays analytics of the users’ interactions back to the application through the server.
Now, if the push notifications are triggered natively by an app they are called in-app or app push notifications. If the same is relayed remotely through a web server on a web browser, they are called web push notifications.
How app push notifications and web push notifications are different?
There is a huge difference between the ways both kinds of notifications communicate with a device. While you need a native mobile app with in-built triggers to send app alerts, web push notifications can be triggered remotely on a web browser by a website server. Mobile apps are not essential to trigger web push notifications.
The look and feel of web pushing are identical to that of app alerts. However, there is a difference in technology. Web push alerts are managed by Cloud servers. Think of it as SMS. You have an SMS app on your phone where you receive messages. The message is sent to you by some other user and is delivered by your telecom service provider.
In the same way, you use an application to create push messages, and they are relayed to a cloud server by the app, which then delivers it to the subscribers. The Cloud server here is identical to the telecom service provider. There are many cloud servers like there are many telecom services.
Here we are going to understand the working of one such server/service from Google: Google’s Firebase Cloud Messaging (FCM) push notification works. It is a free web service from Google. We are going to understand the anatomy of how FCM push notification works, and how different push notification tools in the market use similar services to deliver all kinds of push alerts.
What is FCM?
Before FCM, Google had GCM (Google Cloud Messaging), which was a mobile messaging platform. Marketers used it to deliver messages in real-time. Later they upgraded to FCM. If you see how FCM push notification works, it’s exactly the same as GCM, but now you can send ‘web push notifications’ in addition to simple messages.
FCM in a simple term is an open-source mobile messaging service with push notifications. It still uses the GCM servers to deliver the messages. Developers use it to enable web and mobile applications to push web-based messages and their notifications to their users.
How FCM works in Android?
You can send two types of messages to an Android app (can be any app or Chrome browser app) using FMC:
- Notification messages: Simply display a message content, which is handled by the FCM SDK.
- Data Messages: Display a message with some set interactions. The interactions are handled by the Android app itself.
The Android push notifications through FCM actually treats the Data Messages as notification messages itself. As the interactions in the data messages are handled by the app itself, FCM’s work is just to deliver a notification and the message content. It depends on the key-value pairs of the message if it has to merely display a message or have some optional data payload instructions for the app. For example, open an URL.
You need three things to implement FCM-based push notifications on an Android App:
- A Mobile app
- Connection to the FCM server
- A third-party push server
You need to first add Firebase to your Android app project. Next, you need to know how to get FCM registration token by registering on FCM, also called as API tokens/IDs. Once, you have the FCM token, you need to configure the same on your Android app to establish a connection with the FCM servers.
Now, you need a 3rd party push server to send notifications from mobile app to the FCM servers. Traditionally, you need to use the Google Play store for this, which requires further setup with the Google Play services APK. However, you can skip this part by using a third-party push notification server lie Pushcrew or Push Engage, or can set up you’re your self-hosted push notification server using a tool like PushMaze.
Be it any server you select, both the options will give you a dashboard from where you can manage your push notifications, subscribers, push campaigns, and Analytics.
How FCM works in iOS?
FCM in iOS works very similar to that of Android. Except for FCM here communicates with the Apple Push Notifications Service. You need Apple Push Notification Authentication Key for your Apple Developer account. The iOS requests a device token from the Apple Push Notification Service (APNs). The iOS app receives the token, which is used to send Push Notifications to the application identified by the App ID. The FCM sends the notification to APNs and then APNS identifies the FCM Server API before sending them to the iOS device.
Note: If you don’t know how to get FCM server key, you can get it from the dashboard of your Firebase Developer Console.
How does FCM Push Notification work in Web Browsers?
Web push notification works exactly the same as applications in web browsers as well. For example, Google Chrome uses the FCM as their web service to send push notification to the users on the browser. The Chrome browsers on both mobile and desktop were built with FCM. You don’t need to add anything to make it support push notifications.
For example, the Android version of Google Chrome is a mobile app. It offers to push notification controls on two levels. One- as an Android app, you have to allow the Chrome app to receive push notifications of any kind. Second, users have to subscribe to the individual websites for receiving the notifications from them on Google Chrome Notifications.
To Conclude
FCM is a boon to the mobile app and website developers. This free service from Google allows anyone to send free push notifications from apps and websites. Though it’s not possible for general website owners to implement FCM without any coding knowledge. You can still implement it on your website using ready-made push notifications tools in the market. Alternatively, FCM does allow self-hosted to push notifications services. You can create your own self-hosted push notification server if you do not want to subscribe to a premium service.
Leave a Reply