컨텐츠로 건너뛰기

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

터미널 창
bun add @capgo/capacitor-firebase-messaging
bunx cap sync

import

Import
import { 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);

필요한 모든 API가 존재하는지 확인합니다.

항상 true 안드로이드와 iOS에서 반환됩니다.

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
const result = await FirebaseMessaging.isSupported();
console.log(result);

푸시 알림을 받기 위해 앱을 등록합니다. 푸시 메시지를 해당 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.

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

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

주제에 대한 구독을 백그라운드에서 등록합니다.

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;
}
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[];
}

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;
}
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 키 구현 세부 정보를 위한 장치 장치 구현 세부 정보를 위한, 패키지 패키지 구현 세부 정보를 위한.