Skip to content

Getting Started

GitHub

CapgoのAIアシストセットアップを使用してプラグインをインストールできます。AIツールにCapgoスキルを追加するには、以下のコマンドを実行してください。

ターミナル画面
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

次に、以下のプロンプトを使用してください。

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-firebase-messaging` plugin in my project.

Manualセットアップを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。

ターミナル画面
bun add @capgo/capacitor-firebase-messaging
bunx cap sync
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';

プッシュ通知を受信するための許可を確認する

On Androidこのメソッドは、Android 13 以降のみで実行する必要があります。

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.checkPermissions();

プッシュ通知を受信するための許可を要求する

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トークンを取得し、Messaging インスタンスに送信するプッシュメッセージを送信できます。このメソッドは、FCM 自動初期化も再有効にします。

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.getToken();

deleteToken

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteToken();

getDeliveredNotifications

__CAPGO_KEEP_3__

__CAPGO_KEEP_4__

__CAPGO_KEEP_5__

__CAPGO_KEEP_0__

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.getDeliveredNotifications();

removeDeliveredNotifications

__CAPGO_KEEP_7__

__CAPGO_KEEP_0__

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.removeDeliveredNotifications({} as RemoveDeliveredNotificationsOptions);

通知画面からすべての通知を削除します。

注意:この機能は、ローカル通知やFCM通知を含めて、すべての通知を削除します。

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.removeAllDeliveredNotifications();

バックグラウンドでトピックにサブスクライブします。

AndroidおよびiOSのみ対応です。

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.subscribeToTopic({} as SubscribeToTopicOptions);

バックグラウンドでトピックからアンサブスクライブします。

AndroidおよびiOSのみ対応です。

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.unsubscribeFromTopic({} as UnsubscribeFromTopicOptions);

通知チャンネルの作成

Only available for Android (SDK 26+).

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.createChannel({} as CreateChannelOptions);

通知チャンネルの削除

Only available for Android (SDK 26+).

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteChannel({} as DeleteChannelOptions);

通知チャンネルのリスト

Only available for Android (SDK 26+).

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.listChannels();
export interface PermissionStatus {
/**
* @since 0.2.2
*/
receive: PermissionState;
}
export interface IsSupportedResult {
/**
* @since 0.3.1
*/
isSupported: boolean;
}
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;
}
export interface GetTokenResult {
/**
* @since 0.2.2
*/
token: string;
}

GetDeliveredNotificationsResult

通知が届いた結果セクション
export interface GetDeliveredNotificationsResult {
/**
* @since 0.2.2
*/
notifications: Notification[];
}
export interface RemoveDeliveredNotificationsOptions {
/**
* @since 0.4.0
*/
notifications: Notification[];
}
export interface SubscribeToTopicOptions {
/**
* The name of the topic to subscribe.
*
* @since 0.2.2
*/
topic: string;
}
export interface UnsubscribeFromTopicOptions {
/**
* The name of the topic to unsubscribe from.
*
* @since 0.2.2
*/
topic: string;
}
export type CreateChannelOptions = Channel;
export interface DeleteChannelOptions {
/**
* The channel identifier.
*
* @since 1.4.0
*/
id: string;
}
export interface ListChannelsResult {
channels: Channel[];
}

TokenReceivedListener

TokenReceivedListener

トークンを受け取ったイベントを受け取るコールバック

export type TokenReceivedListener = (event: TokenReceivedEvent) => void;

このページはプラグインから生成されています。 src/definitions.tsパブリック API がアップストリームで変更されたときは、再度同期を実行してください。

Capgo を使用している場合 Getting Started ダッシュボードと API の作業を計画するには、接続してください。 API の概要 API の概要の実装詳細について 導入 導入の実装詳細について API のキー API のキーに関する実装詳細について デバイス デバイスの実装詳細について、 バンドル バンドルの実装詳細について。