Skip to content

시작하기

터미널 창
bun add @capgo/capacitor-firebase-messaging
bunx cap sync
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';

API 개요

API 개요

푸시 알림을 받기 위한 권한이 있는지 확인합니다.

켜짐 안드로이드안드로이드 13 이상에서만 이 메서드를 호출해야 합니다.

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

푸시 알림을 받기 위한 권한을 요청합니다.

켜짐 안드로이드안드로이드 13 이상에서만 이 메서드를 호출해야 합니다.

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

푸시 알림을 받기 위해 앱을 등록합니다. 푸시 메시지를 해당 Messaging 인스턴스로 보내기 위해 사용할 수 있는 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 알림만 반환하는 것이 아닙니다.

안드로이드에서, 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();

배경에서 주제 구독

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);

__CAPGO_KEEP_1__ 채널을 삭제합니다.

SDK Android에서만 사용 가능합니다 (26+).

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

__CAPGO_KEEP_1__ 사용 가능한 알림 채널 목록입니다.

SDK Android에서만 사용 가능합니다 (26+).

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

__CAPGO_KEEP_0__ 타입 참조

__CAPGO_KEEP_1__ 타입 참조
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;
}
export interface GetDeliveredNotificationsResult {
/**
* @since 0.2.2
*/
notifications: Notification[];
}

RemoveDeliveredNotificationsOptions

"RemoveDeliveredNotificationsOptions" 섹션 제목
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;

DeleteChannelOptions

제목 '채널 삭제 옵션'
export interface DeleteChannelOptions {
/**
* The channel identifier.
*
* @since 1.4.0
*/
id: string;
}
export interface ListChannelsResult {
channels: Channel[];
}

토큰 수신 이벤트를 받을 때 호출되는 콜백 함수.

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

실제 데이터의 원천

실제 데이터의 원천 섹션

이 페이지는 플러그인의 src/definitions.ts. upstream에서 변경된 경우 public API를 다시 동기화할 때.