capacitor-push-notifications
Original:🇺🇸 English
Translated
Guides the agent through setting up and using push notifications in Capacitor apps using Firebase Cloud Messaging via the @capacitor-firebase/messaging plugin. Covers Firebase project setup, plugin installation, platform-specific configuration (Android, iOS, Web), APNs certificate setup, requesting permissions, retrieving FCM tokens, listening for notifications, topic subscriptions, notification channels, and testing. Do not use for local notifications, non-Firebase push providers, migrating Capacitor apps or plugins, or non-Capacitor mobile frameworks.
3installs
Sourcecapawesome-team/skills
Added on
NPX Install
npx skill4agent add capawesome-team/skills capacitor-push-notificationsTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Capacitor Push Notifications
Set up and use push notifications in Capacitor apps using Firebase Cloud Messaging (FCM) via the plugin.
@capacitor-firebase/messagingPrerequisites
- Capacitor 6, 7, or 8 app.
- Node.js and npm installed.
- A Firebase project. Create one at Firebase console if needed.
- For iOS: A paid Apple Developer Program membership and Xcode installed.
- For Android: Android Studio installed.
- must not be installed — it conflicts with
@capacitor/push-notifications.@capacitor-firebase/messaging
Agent Behavior
- Guide step-by-step. Walk the user through the process one step at a time. Never present multiple unrelated questions at once.
- Auto-detect before asking. Check the project for platforms (,
android/), build tools, framework, andios/dependencies. Only ask the user when something cannot be detected.package.json - One decision at a time. When a step requires user input, ask that single question, wait for the answer, then continue.
- Present clear options. Provide concrete choices (e.g., "Do you want to configure topic subscriptions? (yes/no)") instead of open-ended questions.
Procedures
Step 1: Analyze the Project
Auto-detect the following by reading project files — do not ask the user for information that can be inferred:
- Platforms: Check which directories exist (,
android/). These are the platforms to configure.ios/ - Build tool / framework: Check for ,
vite.config.ts,angular.json,webpack.config.js, etc.next.config.js - Capacitor version: Read version from
@capacitor/core.package.json - Conflicting plugins: Check if is in
@capacitor/push-notifications. If found, warn the user it must be removed before proceeding:package.jsonbashnpm uninstall @capacitor/push-notifications
Step 2: Set Up Firebase
Check if Firebase is already configured in the project:
- Android: Check if exists.
android/app/google-services.json - iOS: Check if exists.
ios/App/App/GoogleService-Info.plist
If Firebase is not configured for a detected platform, read and guide the user through the Firebase setup for each missing platform.
references/firebase-setup.mdStep 3: Install the Plugin
bash
npm install @capacitor-firebase/messaging firebase
npx cap syncStep 4: Configure Android
Skip if does not exist.
android/Read and apply the Android-specific configuration.
references/android-setup.mdStep 5: Configure iOS
Skip if does not exist.
ios/Read and apply the iOS-specific configuration. This includes APNs key/certificate setup, modifications, and enabling capabilities.
references/ios-setup.mdAppDelegate.swiftStep 6: Configure Web (if applicable)
If the project targets the web (detected via build tool config or user confirmation):
Read and apply the Web-specific configuration.
references/web-setup.mdStep 7: Configure Capacitor Plugin Options
Ask the user if they want to customize iOS foreground notification presentation. If yes, update or :
capacitor.config.jsoncapacitor.config.tsjson
{
"plugins": {
"FirebaseMessaging": {
"presentationOptions": ["alert", "badge", "sound"]
}
}
}Available options: , , , . Default is .
badgesoundalertcriticalAlert["alert", "badge", "sound"]Step 8: Add Push Notification Code
Read and add the push notification code to the project. Adapt imports and structure to match the user's framework.
references/implementation.mdThe implementation covers:
- Requesting permissions
- Retrieving the FCM token
- Listening for incoming notifications
- Handling notification taps
Step 9: Configure Optional Features
Ask the user which optional features to enable:
- Topic subscriptions — Subscribe/unsubscribe to FCM topics (Android/iOS only).
- Notification channels — Create custom Android notification channels (Android SDK 26+ only).
- Token refresh listener — Listen for FCM token changes.
For each selected feature, read and apply the relevant code.
references/implementation.mdStep 10: Sync and Test
-
Sync the project:bash
npx cap sync -
Readand guide the user through sending a test notification via the Firebase Console.
references/testing.md
Error Handling
- conflict: The
@capacitor/push-notificationsplugin cannot coexist with@capacitor-firebase/messaging. Uninstall the conflicting plugin:@capacitor/push-notifications.npm uninstall @capacitor/push-notifications && npx cap sync - iOS: No push notifications received: Verify APNs key/certificate is uploaded to Firebase Console. Verify Push Notifications and Background Modes capabilities are enabled. Verify contains the required delegate methods.
AppDelegate.swift - iOS: not called: Ensure the Push Notifications capability is added in Xcode under Signing & Capabilities. Check that the app's bundle ID matches the one registered in Firebase and Apple Developer portal.
didRegisterForRemoteNotificationsWithDeviceToken - Android: No push notifications received: Verify is at
google-services.json. Verify the Google services Gradle plugin is applied.android/app/google-services.json - Android: White square notification icon: The notification icon must be white pixels on a transparent background. Application icons with color will render as a white square. Add a dedicated push notification icon.
- Web: fails: Ensure the VAPID key is correct. Ensure
getToken()exists at the root of the domain. Check that the browser supports the Push API.firebase-messaging-sw.js - FCM token is : Ensure
nullwas called and returnedrequestPermissions()before callinggranted. On iOS, verify the device is not a simulator (simulators cannot receive push notifications).getToken() - returns
checkPermissions(): The user has permanently denied notification permissions. Guide them to re-enable via device settings (Settings > App > Notifications).denied - Android 13+: No permission prompt: On Android 13 (API 33) and above, must be called explicitly. Earlier Android versions grant notification permission by default.
requestPermissions()