Live_Update_Notifcation_Android
Live_Update_Notifcation_Android copied to clipboard
This repository provides a working example of implementing Live Update Notifications on Android 16 ( Android U). It demonstrates how to leverage both Firebase Cloud Messaging (FCM) and local notificat...
Live Update Notification Android
This repository provides a working example of implementing Live Update Notifications on Android 16 ( Android U). It demonstrates how to leverage both Firebase Cloud Messaging (FCM) and local notifications to deliver rich, timely updates to the user.
Examples
π Features
- π Live Notifications support on Android 16
- βοΈ Firebase Cloud Messaging integration
- π¦ Payload handling and dynamic content updates
- π± Local notification example to simulate live updates without a backend
- π‘ Best practices for targeting Android 16+ notification behavior
π¦ Whatβs Inside
- Sample app written in Kotlin
- Firebase integration (with sample payload format)
- Notification channel setup and management
- Code examples to create/update live notifications
π§ Requirements
- Target SDK 36 (Android 16)
- Firebase project (for push notifications)
π Getting Started
1οΈβ£ Clone the Repository
2οΈβ£ Set Up Firebase
- Go to Firebase Console and create a new project (or use an existing one).
- Add an Android app to the Firebase project using your appβs package name.
- π‘ Tip: You can change the application ID (package name) in build.gradle to match your preferred namespace (e.g., com.yourname.app).
- Download the google-services.json file and place it in the /app directory.
- Enable Firebase Cloud Messaging (FCM) in the Firebase Console under Build > Cloud Messaging.
- Launch the app and tap the "Get FCM Token" button:
- The token will be shown in a toast and logged in Logcat
- Copy this token for sending test messages
3οΈβ£ Run the App
- Connect a physical device or use an emulator running Android 16
- Press Run in Android Studio to build and install the app
4οΈβ£ Test Live Notifications
πΉ Option A: Test with Local Notification
- Tap the "Send Local Notification" button in the app
- It creates a live progress notification based on a local NotificationModel instance
πΉ Option B: Test with Firebase Console
- Go to Firebase Console > Cloud Messaging > Send Your First Message
- Enter a title and body (these will be overridden by data payload)
- Open Advanced options β Data
- In the Target section, select Single Device
- Paste the FCM token from the app
- Add the following key-value pairs:
π Example FCM Payload
{
"title": "Live Update Remote Title",
"body": "Live Update Remote Body",
"currentProgress": "80",
"currentProgressSegmentOne": "33",
"currentProgressSegmentTwo": "33",
"currentProgressSegmentThree": "33",
"currentProgressSegmentFour": "33",
"currentProgressPointOne": "33",
"currentProgressPointTwo": "66",
"currentProgressPointThree": "99"
}
-
Click Send Message
π The payload demonstrates segmented and point-based progress tracking in a live notification, perfect for use cases like order tracking, fitness goals, or download status.
Firebase Cloud Messaging (Example)
[!IMPORTANT]
Check my article for the setup :point_right: Implementing Live Update Notifications in Android 16 - Medium :point_left:
Versioning
Target SDK version: 36
Minimum SDK version: 29
Kotlin version: 2.3.0
Gradle version: 9.0.0
References
https://developer.android.com/about/versions/16/features/progress-centric-notifications
https://github.com/android/platform-samples/tree/main/samples/user-interface/live-updates
https://developer.android.com/develop/ui/views/notifications/build-notification#Updating