사용자 가이드
Capacitor에서 리치 알림을 사용하는 방법
capgo/capacitor-rich-notifications 사용
Android 채널, 진행 레이아웃, 액션 버튼, 스케줄링 및 iOS 중단 수준과 같은 로컬 알림
설치
bun add @capgo/capacitor-rich-notifications
bunx cap sync
이 플러그인이 제공하는 것
checkPermission- 로컬 알림 권한 상태를 확인하세요.requestPermission- 로컬 알림 권한을 요청하세요.createChannel- 안드로이드 알림 채널을 생성하세요.createChannelGroup- 안드로이드 채널 그룹을 생성하세요.deleteChannel- 안드로이드 알림 채널을 삭제하세요.display- 즉시 로컬 알림을 표시하세요.schedule- 나중에 로컬 알림을 예약하세요.cancel- 특정 알림 ID로 알림을 취소하세요.cancelAll- 이 플러그인이 관리하는 모든 알림을 취소하세요.getDisplayed- 앱을 열 때 표시된 알림 목록을 확인하세요.getPending- 아직 표시되지 않은 예약된 알림 목록을 확인하세요.getInitialNotification- 앱을 열 때 표시된 알림을 반환하세요.setBadge- iOS 앱 아이콘 배지 수를 설정하세요.registerActions- 재사용 가능한 액션 카테고리를 등록하세요.getPluginVersion- 플랫폼 구현 버전 마커를 반환합니다.addListener- 누르기 및 취소 이벤트를 듣세요.
예시 사용
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/plugins/rich-notifications/