Getting Started
このプラグインのインストール手順とフルマークダウンガイドを含むセットアッププロンプトをコピーする。
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.
Install
インストールbun add @capgo/capacitor-firebase-messagingbunx cap syncImport
インポートimport { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';API オーバービュー
API オーバービューcheckPermissions
__CAPGO_KEEP_1__push通知を受信する権限があるかどうかを確認します。
On Android__CAPGO_KEEP_0__
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.checkPermissions();requestPermissions
「requestPermissions」セクションプッシュ通知を受信するためのパーミッションを求めます。
オン Android__CAPGO_KEEP_0__
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.requestPermissions();isSupported
「isSupported」セクション必要なすべてのAPIが存在するかどうかを確認します。
常に true AndroidおよびiOSで利用可能です。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.isSupported();getToken
getTokenのセクションアプリをプッシュ通知を受信するために登録します。 FCMトークンを取得し、Messagingインスタンスに送信するプッシュメッセージを送信できます。
このメソッドは、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通知のデータフィールドは含まれません。
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
「createChannel」セクション通知チャンネルを作成します。
Android (SDK 26+) のみで利用可能です。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.createChannel({} as CreateChannelOptions);deleteChannel
「deleteChannel」セクション通知チャンネルを削除します。
Android (SDK 26+) のみで利用可能です。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteChannel({} as DeleteChannelOptions);listChannels
「listChannels」セクション利用可能な通知チャンネルの一覧を表示します。
Android (SDK 26+) のみで利用可能です。
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.listChannels();Type Reference
「Type Reference」セクションPermissionStatus
「PermissionStatus」セクションexport interface PermissionStatus { /** * @since 0.2.2 */ receive: PermissionState;}IsSupportedResult
「IsSupportedResult」セクションexport interface IsSupportedResult { /** * @since 0.3.1 */ isSupported: boolean;}GetTokenOptions
「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
「GetTokenResult」セクションのタイトルexport interface GetTokenResult { /** * @since 0.2.2 */ token: string;}GetDeliveredNotificationsResult
「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
「TokenReceivedListener」セクショントークン受信イベントを受け取るコールバック
export type TokenReceivedListener = (event: TokenReceivedEvent) => void;真実の源
「真実の源」セクションこのページはプラグインの src/definitions.ts. upstream の 公開 API が変更されたときに再度同期してください。
Getting Startedから続けてください
「Getting Startedから続けてください」のセクション「Getting Startedから続けてください」を使用している場合 「Getting Startedから続けてください」を使用してダッシュボードと__CAPGO_KEEP_0__の操作を計画するには APIの概要 APIの概要の実装詳細については for the implementation detail in API Overview, 「導入」の実装詳細については __CAPGO_KEEP_0__のキー APIのキーに関する実装詳細については for the implementation detail in API Keys, デバイス __CAPGO_KEEP_0__の実装詳細についての情報は、デバイスのページで確認できます。 __CAPGO_KEEP_0__ __CAPGO_KEEP_1__ページ