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.
설치
설치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 Setup을 선호한다면, 플러그인을 설치하기 위해 다음 명령어를 실행하고 아래의 플랫폼별 지침을 따르세요:
bun add @capgo/capacitor-firebase-messagingbunx cap syncimport
Importimport { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';API 개요
API 개요checkPermissions
권한 확인푸시 알림을 받을 수 있는 권한을 확인하세요.
On 안드로이드, 이 메소드는 안드로이드 13 이상에서만 호출해야 합니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.checkPermissions();console.log(result);requestPermissions
권한 요청푸시 알림을 받을 수 있는 권한을 요청하세요.
On 안드로이드Android 13 이상일 때만 이 메서드를 호출해야 합니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.requestPermissions();console.log(result);isSupported
isSupported 섹션필요한 모든 API가 존재하는지 확인합니다.
항상 true 안드로이드와 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
제목: deleteTokenFCM 토큰을 삭제하고 앱을 등록 해제하여 푸시 알림을 받지 않도록 합니다. 사용자가 로그아웃 할 때 예를 들어 호출할 수 있습니다.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteToken();getDeliveredNotifications
제목: getDeliveredNotifications알림이 화면에 표시되는 알림 목록을 가져옵니다.
주의: 이 메서드는 모든 전달된 알림을 반환하며, 지역 알림만 반환하지 않습니다.
안드로이드에서, FCM 알림의 데이터 필드는 포함되지 않습니다.
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"알림을 모두 삭제합니다.
주의: 모든 전달된 알림을 삭제합니다. (지역 알림 포함).
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알림 채널 만들기
안드로이드 (SDK 26+) 전용
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.createChannel({ id: 'id-123', name: 'example',});deleteChannel
deleteChannel알림 채널 삭제
안드로이드 (SDK 26+) 전용
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteChannel({ id: 'id-123' });listChannels
listChannels사용 가능한 알림 채널 목록
안드로이드 (SDK 26+) 전용
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.listChannels();console.log(result);타입 참조
타입 참조 섹션PermissionStatus
권한 상태 섹션export interface PermissionStatus { /** * @since 0.2.2 */ receive: PermissionState;}IsSupportedResult
지원 여부 결과 섹션export interface IsSupportedResult { /** * @since 0.3.1 */ isSupported: boolean;}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
토큰 가져오기 결과 섹션export interface GetTokenResult { /** * @since 0.2.2 */ token: string;}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공개 API이 업스트림에서 변경될 때 다시 싱크를 실행하세요.
Getting Started에서 계속
Getting Started에서 계속Getting Started을 사용하여 대시보드와 __CAPGO_KEEP_0__를 계획하고 운영할 경우에 Getting Started 설정 대시보드와 API 작업을 계획하고 연결하세요. API 개요 API 구현 세부 정보를 위한 소개 소개 구현 세부 정보를 위한 API 키 API 키 구현 세부 정보를 위한 장치 장치 구현 세부 정보를 위한, 패키지 패키지 구현 세부 정보를 위한.