가이드
Capacitor에서 Rich Notifications 사용법
@capgo/capacitor-rich-notifications 사용하기
Android 채널, 프로그레스 레이아웃, 액션 버튼, 스케줄링, iOS interruption level을 지원하는 로컬 알림.
설치
bun add @capgo/capacitor-rich-notifications
bunx cap sync
플러그인이 제공하는 기능
checkPermission- 로컬 알림 권한 상태 확인requestPermission- 로컬 알림 권한 요청createChannel- Android 알림 채널 생성createChannelGroup- Android 채널 그룹 생성deleteChannel- Android 알림 채널 삭제display- 로컬 알림 즉시 표시schedule- 로컬 알림 예약cancel- ID로 알림 하나 취소cancelAll- 이 플러그인으로 관리되는 모든 알림 취소getDisplayed- 알림창 또는 알림 센터에 표시된 알림 목록 조회getPending- 아직 표시되지 않은 예약 알림 목록 조회getInitialNotification- 앱을 연 알림이 있으면 반환setBadge- iOS에서 앱 아이콘 배지 수를 설정합니다.registerActions- 재사용 가능한 액션 카테고리를 등록합니다.getPluginVersion- 플랫폼 구현체의 버전 마커를 반환합니다.addListener- press 및 dismiss 이벤트를 수신합니다.
사용 예시
requestPermission 및 display
import { RichNotifications } from '@capgo/capacitor-rich-notifications';
await RichNotifications.requestPermission();
await RichNotifications.createChannel({
id: 'messages',
name: 'Messages',
importance: 'high',
});
await RichNotifications.display({
title: 'Hello',
body: 'Tap to open the app',
channelId: 'messages',
});
schedule
import { RichNotifications } from '@capgo/capacitor-rich-notifications';
await RichNotifications.schedule({
notification: {
id: 'reminder-1',
title: 'Reminder',
body: 'Your appointment starts soon',
channelId: 'messages',
},
trigger: { type: 'timestamp', timestamp: Date.now() + 60_000 },
});
전체 레퍼런스
- GitHub: https://github.com/Cap-go/capacitor-rich-notifications/
- Docs: /docs/plugins/rich-notifications/