はじめから
セットアップのプロンプトをコピーして、インストールの手順とこのプラグインのフルマークダウンガイドを含む。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-firebase-messaging`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/firebase-messaging/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
「インストール」のセクションbun add @capgo/capacitor-firebase-messagingbunx cap syncimport { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';API の概要
Section titled “API の概要”checkPermissions
Section titled “checkPermissions”プッシュ通知を受信するための許可を確認する
オン AndroidAndroid 13 以降では、このメソッドを呼び出す必要があります。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.checkPermissions();requestPermissions
Section titled “requestPermissions”プッシュ通知を受信するための許可を求める
On Android, this method only needs to be called on Android 13+.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.requestPermissions();isSupported
クリップボードにコピー「isSupported」セクション
必要なすべてのAPIが存在するかどうかを確認します。 true 常に
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.isSupported();getToken
クリップボードにコピー「getToken」セクション
アプリをプッシュ通知を受信できるように登録します。 プッシュメッセージを送信するために使用できるFCMトークンを返します。このメソッドはFCMの自動初期化も再有効化します。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.getToken();deleteToken
「deleteToken」セクションFCMトークンを削除し、プッシュ通知を受信しないようにアプリをアンリレーションします。 ユーザーがログアウトしたときなどに呼び出されることがあります。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteToken();getDeliveredNotifications
「getDeliveredNotifications」セクション通知画面で表示される通知の一覧を取得します。 注: このメソッドは、FCM通知のみを返しません。ローカル通知も含めて、すべての通知を返します。 Androidの場合、FCM通知のデータフィールドは含まれません。
クリップボードにコピー
「removeDeliveredNotifications」セクション
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.getDeliveredNotifications();removeDeliveredNotifications
クリップボードにコピー「removeDeliveredNotifications」セクション
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.removeDeliveredNotifications({} as RemoveDeliveredNotificationsOptions);removeAllDeliveredNotifications
「removeAllDeliveredNotifications」セクション通知をすべて削除します。
注: これは、FCM 通知のみを削除するのではなく、すべての通知 (ローカル通知含む) を削除します。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.removeAllDeliveredNotifications();subscribeToTopic
「subscribeToTopic」セクションバックグラウンドでトピックにサブスクライブします。
Android と iOS のみに対応しています。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.subscribeToTopic({} as SubscribeToTopicOptions);unsubscribeFromTopic
「unsubscribeFromTopic」セクションバックグラウンドでトピックからアンサブスクライブします。
Android と iOS のみに対応しています。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.unsubscribeFromTopic({} as UnsubscribeFromTopicOptions);createChannel
Android用の通知チャンネルを作成します。通知チャンネルの作成
Android用のみ(SDK 26+)。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.createChannel({} as CreateChannelOptions);deleteChannel
Android用の通知チャンネルの削除通知チャンネルの削除
Android用のみ(SDK 26+)。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteChannel({} as DeleteChannelOptions);listChannels
Android用の通知チャンネルのリスト通知チャンネルのリスト
Android用のみ(SDK 26+)。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.listChannels();種類リファレンス
種類リファレンスセクションPermissionStatus
許可状態セクションexport interface PermissionStatus { /** * @since 0.2.2 */ receive: PermissionState;}IsSupportedResult
サポートされているかどうかの結果セクションexport interface IsSupportedResult { /** * @since 0.3.1 */ isSupported: boolean;}GetTokenOptions
トークン取得オプションセクションexport interface GetTokenOptions { /** * Your VAPID public key, which is required to retrieve the current registration token on the web. * * Only available for Web. */ vapidKey?: string; /** * The service worker registration for receiving push messaging. * If the registration is not provided explicitly, you need to have a `firebase-messaging-sw.js` at your root location. * * Only available for Web. */ serviceWorkerRegistration?: ServiceWorkerRegistration;}GetTokenResult
トークン取得結果セクションexport interface GetTokenResult { /** * @since 0.2.2 */ token: string;}GetDeliveredNotificationsResult
配信された通知結果セクションexport interface GetDeliveredNotificationsResult { /** * @since 0.2.2 */ notifications: Notification[];}RemoveDeliveredNotificationsOptions
「RemoveDeliveredNotificationsOptions」セクションexport interface RemoveDeliveredNotificationsOptions { /** * @since 0.4.0 */ notifications: Notification[];}SubscribeToTopicOptions
「SubscribeToTopicOptions」セクションexport interface SubscribeToTopicOptions { /** * The name of the topic to subscribe. * * @since 0.2.2 */ topic: string;}UnsubscribeFromTopicOptions
「UnsubscribeFromTopicOptions」セクションexport interface UnsubscribeFromTopicOptions { /** * The name of the topic to unsubscribe from. * * @since 0.2.2 */ topic: string;}CreateChannelOptions
「CreateChannelOptions」セクションexport type CreateChannelOptions = Channel;DeleteChannelOptions
「DeleteChannelOptions」セクションexport interface DeleteChannelOptions { /** * The channel identifier. * * @since 1.4.0 */ id: string;}ListChannelsResult
「ListChannelsResult」セクションexport interface ListChannelsResult { channels: Channel[];}TokenReceivedListener
トークン受信リスナートークンを受信したイベントを受け取るコールバック
export type TokenReceivedListener = (event: TokenReceivedEvent) => void;このページはプラグインから生成されています。 src/definitions.ts上流で公開された API が変更された場合、再度 Sync を実行してください。
Getting Started から続けて
Section titled “Getting Started から続けて”Capgo を使用している場合、ダッシュボードと __CAPGO_KEEP_0__ の計画と操作を行うには、接続してください。 Getting Started to plan dashboard and API operations, connect it with API の概要 API の概要の実装詳細について 導入 導入の実装詳細について API のキー API のキーに関する実装詳細について デバイス デバイスの実装詳細について、 バンドル バンドルの実装詳細について。