Skill 詳細
capacitor-push-notifications
Android-relevant only for Capacitor Firebase push-notification setup.
使用前に確認
自動レビューは関連性のみを確認し、安全性や推奨を保証しません。使用前に出典の説明を読んでください。
SKILL.md
これはレビュー時に保存された抜粋です。完全で最新の内容は外部ソースを確認してください。
--- name: capacitor-push-notifications description: "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." metadata: author: capawesome-team source: https://github.com/capawesome-team/skills/tree/main/skills/capacitor-push-notifications --- # Capacitor Push Notifications Set up and use push notifications in Capacitor apps using Firebase Cloud Messaging (FCM) via the `@capacitor-firebase/messaging` plugin. ## Prerequisites 1. **Capacitor 6, 7, or 8** app. 2. Node.js and npm installed. 3. A **Firebase project**. Create one at [Firebase console](https://console.firebase.google.com/) if needed. 4. For **iOS**: A paid [Apple Developer Program](https://developer.apple.com/programs/) membership and Xcode installed. 5. For **Android**: Android Studio installed. 6. `@capacitor/push-notifications` must **not** be installed — it conflicts with `@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/`, `ios/`), build tools, framework, and `package.json` dependencies. Only ask the user when something cannot be detected. - **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: 1. **Platforms**: Check which directories exist (`android/`, `ios/`). These are the platforms to configure. 2. **Build tool / framework**: Check for `vite.config.ts`, `angular.json`, `webpack.config.js`, `next.config.js`, etc. 3. **Capacitor version**: Read `@capacitor/core` version from `package.json`. 4. **Conflicting plugins**: Check if `@capacitor/push-notifications` is in `package.json`. If found, warn the user it must be removed before proceeding: ```bash npm uninstall @capacitor/push-notifications ``` ### Step 2: Set Up Firebase Check if Firebase is already configured in the project: - **Android**: Check if `android/app/google-services.json` exists. - **iOS**: Check if `ios/App/App/GoogleService-Info.plist` exists. If Firebase is **not** configured for a detected platform, read `references/firebase-setup.md` and guide the user through the Firebase setup for each missing platform. ### Step 3: Install the Plugin ```bash npm install @capacitor-firebase/messaging firebase npx cap sync ``` ### Step 4: Configure Android Skip if `android/` does not exist. Read `references/android-setup.md` and apply the Android-specific configuration. ### Step 5: Configure iOS Skip if `ios/` does not exist. Read `references/ios-setup.md` and apply the iOS-specific configuration. This includes APNs key/certificate setup, `AppDelegate.swift` modifications, and enabling capabilities. ### Step 6: Configure Web (if applicable) If the project targets the web (detected via build tool config or user confirmation): Read `references/web-setup.md` and apply the Web-specific configuration. ### Step 7: Configure Capacitor Plugin Options Ask the user if they want to customize iOS foreground notification presentation. If yes, update `capacitor.config.json` or `capacitor.config.ts`: ```jsonGitHub で全文を読む (外部ページ)