Push Notifications in Android Platform
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
On Android, push notifications are usually delivered through Firebase Cloud Messaging, or FCM. The complete flow has three parts: the device registers for a token, your backend sends a message to FCM, and the app receives that message and turns it into a user-visible notification.
Core pieces of the Android push stack
An Android push setup normally includes:
- Firebase in the Android app,
- an FCM registration token for the device or app instance,
- a backend or Firebase console message sender,
- and Android notification channels for user-visible delivery.
FCM handles the transport, while your app decides how to display the message once it arrives.
Add Firebase Messaging and declare the service
At the app level, add the messaging dependency:
Then implement a FirebaseMessagingService:
And register it in AndroidManifest.xml:
Build a notification channel and post the notification
On Android 8.0 and higher, notifications need a channel:
And the actual notification can be built with NotificationCompat:
Android 13 and newer require notification permission
Starting with Android 13, most apps must request the POST_NOTIFICATIONS runtime permission before posting non-exempt notifications. That means a modern Android notification flow needs both the manifest entry and a runtime permission request.
At runtime, request it from an activity when appropriate to your UX:
Without that permission, the app may receive an FCM message but fail to show a visible notification.
Sending messages and handling payloads
FCM supports two common message styles:
- notification messages, which focus on user-visible title and body content,
- data messages, which give your app structured custom fields to handle itself.
Data messages are often better when the app needs to decide exactly how navigation, caching, or in-app state updates should work.
Common Pitfalls
The biggest mistake is treating FCM setup as complete after the dependency is added. The app still needs a registered messaging service, a notification channel, and permission handling on recent Android versions.
Another common issue is ignoring token lifecycle. FCM tokens can change, so if your backend targets individual devices, it must accept token updates from onNewToken.
Be careful with notification payloads in the background. Depending on the message type and app state, the system may display parts of the message automatically while your data-handling code runs differently than expected.
Finally, notifications are a product surface, not just a transport feature. Bad channel naming, noisy defaults, or permission prompts shown too early can hurt user trust even when the code is technically correct.
Summary
- Android push notifications are typically built on Firebase Cloud Messaging.
- The app needs Firebase Messaging, a
FirebaseMessagingService, and notification-channel setup. - Android 13 and higher generally require the
POST_NOTIFICATIONSruntime permission. - FCM token management matters if your backend targets specific devices.
- A reliable push system depends on both transport setup and good notification UX.
Related reading
- Putting a LazyVStack or LazyHStack in a ScrollView causes stuttering
- R cannot be resolved - Android error
- R cannot be resolved - Android error
- R cannot be resolved to a variable?
- RCTBundleURLProvider.h file not found - AppDelegate.m
- React-Native Error Failed to install CocoaPods dependencies for iOS project, which is required by this template
- React-native How to build for ios from windows
- React Native android build failed. SDK location not found
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.