내용으로 건너뛰기

시작하기

GitHub

설치

설치

AI-Assisted Setup을 사용하여 플러그인을 설치할 수 있습니다. 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 Setup을 선호한다면, 플러그인을 설치하기 위해 다음 명령어를 실행하고 아래의 플랫폼별 지침을 따르세요:

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

checkPermissions

권한 확인 섹션

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

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

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

requestPermissions

“권한 요청” 섹션

푸시 알림을 받을 수 있는 권한을 요청하세요.

Android Android 13 이상에서만 이 메서드를 호출해야 합니다.클립보드에 복사

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

클립보드에 복사

권한 가져오기 true getToken

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

getToken

getToken

푸시 알림을 받기 위해 앱을 등록하세요. FCM 토큰을 반환하여 푸시 메시지를 해당 메시징 인스턴스로 전송할 수 있습니다.

이 메서드는 FCM 자동 초기화를 다시 활성화합니다.

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

푸시 알림을 받지 않도록 앱을 등록 해제하고 FCM 토큰을 삭제하세요. 예를 들어 사용자가 로그아웃 할 때 호출할 수 있습니다.

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

알림 화면에서 보이는 알림 목록을 가져옵니다.

주의: 이 메서드는 모든 전달된 알림을 반환하며, 지역 알림만 반환하지 않습니다.

FCM 알림의 데이터 필드는 Android에서 포함되지 않습니다.

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

배경에서 주제에 구독합니다.

안드로이드 및 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

사용 가능한 알림 채널 목록을 표시합니다.

안드로이드 (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;
}
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

Section titled “받은 알림 결과”
export interface GetDeliveredNotificationsResult {
/**
* @since 0.2.2
*/
notifications: Notification[];
}

RemoveDeliveredNotificationsOptions

Section titled “받은 알림 삭제 옵션”
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;
}

ListChannelsResult

ListChannelsResult
export interface ListChannelsResult {
channels: Channel[];
}

TokenReceivedListener

TokenReceivedListener

토큰 수신 이벤트를 받는 콜백입니다.

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

실질적인 출처

실질적인 출처

이 페이지는 플러그인의 src/definitions.ts업스트림에서 pubic API이 변경될 때 다시 싱크를 실행하세요.

시작부터 계속

실질적인 출처

만약에 시작하기 API를 위한 계획 대시보드와 API 운영을 계획하고 연결하세요. API 개요 API 개요에서 구현 세부 정보를 참조하세요. 소개 소개에서 구현 세부 정보를 참조하세요. API 키 API 키에서 구현 세부 정보를 참조하세요. 장치 장치에서 구현 세부 정보를 참조하세요. 블록 블록에서 구현 세부 정보를 참조하세요.