ガイド
Capacitor でリッチな通知を使用する方法
Using @capgo/capacitor-rich-notifications
Androidチャンネル、進行状況レイアウト、アクションボタン、スケジュール、iOS中断レベルを備えたローカル通知
インストール
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- 押し下しと消去イベントをリスンします。
- 例えば
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 },
});
- __CAPGO_KEEP_0__:
- GitHub: https://github.com/Cap-go/capacitor-rich-notifications/
- ドキュメント: /docs/plugins/rich-notifications/