How do push notifications work? (Architecture design)
Published 2 years ago
|
Notifications are a great way to engage your users and is a must-have feature in most of the applications out there. One study shows that 61% of new app users who receive push notifications launched the app within the first month. This is more than double the 28% of installers who did not receive push notifications. How does it work?The only way to deliver push notifications to ios and android devices, is using Push Notifications Gateways
๐ง Both gateways are services that expose a Web API for sending push notifications to users through HTTP requests. Letโs use an exampleLetโs say you are building a social media app, and whenever a Stranger follows Alice, we want to notify Alice about this. The eventThe flow starts from an event: a Stranger follows Alice Your backendWe first process the event itself by saving the follow information in the database. Then, we save the data about the notification in the database to display the In-app notifications. When Alice will check her notifications tab in the app, we will query this table to get her notifications. Lastly, we will send a Push Notification to Alice. To do that, we will use the Firebase Cloud Messaging service. As we can see, our backend does not have to know if Alice is using an iOS device or an Android device. Firebase Cloud Messaging (FCM)Firebase Cloud Messaging handles the low-level logic of sending the notification. Platform level transport layerA platform-level transport layer routes the message to the targeted device, handles message delivery, and applies platform-specific configuration where appropriate. If Alice is using an Android device, FCM will use the Android transport layer. If Alice is using an iOS device, FCM will make a call to APN (Apple Push Notifications) to deliver the notification. Hurray ๐Finally, Alice receive the push notifications and leaves you on seenโฆ. Push tokenFor the above flow to work, we need to identify users in order to know where to send these push notifications. For that we need to store userโs push tokens in our database, and later use it when we have to notify that user. A push token is a unique key that identifies an app installed in a specific device. Learn more about push notificationsThis high-level architecture is actually a sneak-peak from the latest module from Full Stack Mobile Development course. If you want to learn how to implement this example in a real-world application, the enrolment is currently open.
๐ด Join me liveThis Friday we will build a custom Backend for the Nike app using NodeJS and MongoDB. We will then query this backend from React Native using Redux Toolkit Query. It's gonna be a tutorial packed with value, so set a reminder and don't miss it out ๐ ๐ In case you missed it
๐ฅ Press worthy
Did you learn something new today?If you found this email valuable, forward it to one friend or coworker that can benefit from it as well. That would be much appreciated ๐ |