home / skills / hoangnguyen0403 / agent-skills-standard / android-notifications

android-notifications skill

/skills/android/android-notifications

This skill helps you implement Android push notifications with Firebase Cloud Messaging, proper channels, and permission handling for a robust user experience.

npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill android-notifications

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1.3 KB
---
name: Android Notifications
description: Push notifications for Android using Firebase Cloud Messaging and NotificationCompat.
metadata:
  labels: [android, fcm, notifications, push, notification-channels]
  triggers:
    files: ['**/*Notification*.kt', '**/MainActivity.kt']
    keywords: [FirebaseMessaging, NotificationCompat, NotificationChannel, FCM]
---

# Android Notifications

## **Priority: P2 (OPTIONAL)**

Push notifications using Firebase Cloud Messaging.

## Guidelines

- **Service**: Implement `FirebaseMessagingService` for handling background messages.
- **Channels**: Must create `NotificationChannel` for Android 8.0+ compatibility.
- **Permissions**: Request `POST_NOTIFICATIONS` explicitly on Android 13+.
- **Intents**: Handle notification taps in both `onCreate` and `onNewIntent`.
- **Priming**: Show benefit dialog before requesting system permissions.

[Implementation Details](references/implementation.md)

## Anti-Patterns

- **No Missing Channel**: Notifications fail silently without channels on API 26+.
- **No Unconditional Requests**: Don't spam permission dialog on first launch.
- **No Missing Manifest**: Service must be declared with `MESSAGING_EVENT` action.

## Related Topics

android-navigation | android-design-system | mobile-ux-core

Overview

This skill covers implementing push notifications on Android using Firebase Cloud Messaging (FCM) and NotificationCompat. It focuses on reliable background handling, channel creation for API 26+, and permission flows for modern Android. Practical guidance and common anti-patterns help prevent silent failures and poor UX.

How this skill works

The skill explains how to register and implement FirebaseMessagingService to receive background and data messages. It describes creating NotificationChannel for Android 8.0+ and building notifications with NotificationCompat to ensure consistent rendering. It also covers requesting POST_NOTIFICATIONS on Android 13+ and handling notification taps via intents in both onCreate and onNewIntent.

When to use it

  • You need to deliver remote push notifications reliably across Android versions.
  • When implementing background message handling or data messages with custom behavior.
  • When targeting Android 8.0+ where channels are required.
  • When your app requests runtime notification permission on Android 13+.
  • When you need consistent visual and behavioral notification rendering across devices.

Best practices

  • Implement FirebaseMessagingService and handle messages in onMessageReceived for foreground and background flows.
  • Always create NotificationChannel(s) before posting notifications on API 26+ and include sensible importance and descriptions.
  • Request POST_NOTIFICATIONS on Android 13+ with a priming dialog that explains the benefit before showing the system dialog.
  • Handle notification taps in both onCreate and onNewIntent to cover cold and warm start paths.
  • Declare the messaging service in the manifest with the MESSAGING_EVENT action to ensure delivery.
  • Avoid unconditional permission prompts; show contextual explanations or in-app settings first.

Example use cases

  • Transactional alerts such as order updates or payment receipts implemented via FCM data messages.
  • Chat or messaging apps that need to wake the user and route them to the correct conversation on tap.
  • Marketing notifications where channels allow users to opt out of categories without disabling all notifications.
  • Feature flags that enable notification flows only after users agree in-app, reducing permission friction.
  • Background sync triggers where a silent data message prompts the app to refresh content and then show a notification.

FAQ

What happens if I don’t create a NotificationChannel on Android 8+?

Notifications can fail to appear or behave inconsistently; channels are required for proper delivery and user controls on API 26 and above.

When should I request POST_NOTIFICATIONS permission?

Request it only when the user understands the benefit, ideally after a priming dialog or when they opt into notifications in settings, to avoid poor UX and denied permission.