시작하기
이 플러그인의 설치 단계와 전체 마크다운 가이드가 포함된 설정 프롬프트를 복사하세요.
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.
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.수동 설정을 선호한다면, 다음 명령어를 실행하여 플러그인을 설치하고 아래의 플랫폼별 지침을 따르세요:
bun add @capgo/capacitor-firebase-messagingnpx cap sync가져오기
“Import” 섹션import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';빠른 시작
“빠른 시작” 섹션import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.checkPermissions();console.log(result);예시: requestPermissions
“예: requestPermissions” 섹션import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.requestPermissions();console.log(result);예시: isSupported
“예시: isSupported”라는 제목의 섹션import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.isSupported();console.log(result);자주 하는 실수
“흔한 실수” 섹션- 권한: 호출
checkPermissions()그다음requestPermissions()필요할 때. - 리스너: 화면이 언마운트될 때 핸들을 제거합니다.
- 신뢰할 수 있는 소스: 신뢰
src/definitions.tsGitHub 레포지토리에서.
API 개요
“API 개요” 섹션checkPermissions
“checkPermissions” 섹션푸시 알림 수신 권한을 확인하세요.
웹 Android, 이 메서드는 Android 13 이상에서만 호출하면 됩니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.checkPermissions();console.log(result);requestPermissions
“requestPermissions” 섹션푸시 알림 수신 권한을 요청합니다.
웹 Android, 이 메서드는 Android 13 이상에서만 호출하면 됩니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.requestPermissions();console.log(result);isSupported
“isSupported” 섹션필요한 모든 API가 존재하는지 확인합니다.
항상 반환합니다 true Android 및 iOS에서.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.isSupported();console.log(result);getToken
“getToken” 섹션푸시 알림을 수신하도록 앱을 등록합니다. 해당 Messaging 인스턴스에 푸시 메시지를 보낼 수 있는 FCM 토큰을 반환합니다.
이 메서드는 FCM 자동 초기화 기능을 다시 활성화합니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.getToken();// The result holds sensitive values: use it without logging it.deleteToken
“deleteToken” 섹션푸시 알림 수신을 중단하려면 FCM 토큰을 삭제하고 앱 등록을 해제하세요. 예를 들어, 사용자가 로그아웃할 때 호출할 수 있습니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteToken();getDeliveredNotifications
“getDeliveredNotifications” 섹션알림 화면에 표시된 알림 목록을 가져옵니다.
참고: 이 메서드는 FCM 알림뿐만 아니라 로컬 알림을 포함하여 전달된 모든 알림을 반환합니다.
Android에서는 FCM 알림의 data 필드가 포함되지 않습니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.getDeliveredNotifications();console.log(result);removeDeliveredNotifications
“removeDeliveredNotifications” 섹션알림 화면에서 특정 알림을 제거합니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.removeDeliveredNotifications({ notifications: [] });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({ topic: 'topic' });unsubscribeFromTopic
“unsubscribeFromTopic” 섹션백그라운드에서 토픽 구독을 취소합니다.
Android 및 iOS에서만 사용할 수 있습니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.unsubscribeFromTopic({ topic: 'topic' });createChannel
“createChannel” 섹션알림 채널을 생성합니다.
Android(SDK 26+)에서만 사용할 수 있습니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.createChannel({ id: 'id-123', name: 'example',});deleteChannel
“deleteChannel” 섹션알림 채널을 삭제합니다.
Android(SDK 26+)에서만 사용할 수 있습니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteChannel({ id: 'id-123' });listChannels
“listChannels” 섹션사용 가능한 알림 채널을 나열합니다.
Android(SDK 26+)에서만 사용할 수 있습니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.listChannels();console.log(result);타입 레퍼런스
“타입 참조” 섹션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;Source of Truth
“Source Of Truth” 섹션이 페이지는 플러그인의 src/definitions.tsupstream에서 public API가 변경되면 sync를 다시 실행하세요.
시작하기 다음 단계
“Getting Started에서 계속하기” 섹션사용 중이라면 시작하기 대시보드 및 API 운영을 계획하려면, 이를 다음과 연결하세요 API 개요 구현 세부 사항은 API 개요에서 소개 구현 세부 사항은 소개에서 API 키 구현 세부 사항은 API 키에서 기기 구현 세부 사항은 기기에서, 그리고 번들 Bundles의 구현 세부 사항은