メインコンテンツへスキップ

スタートガイド

GitHub

AIアシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いのAIツールに Capgo のスキルを追加してください:

ターミナル
bunx 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-rich-notifications` plugin in my project.

手動セットアップを希望する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:

ターミナル
bun add @capgo/capacitor-rich-notifications
bunx cap sync
import { RichNotifications } from '@capgo/capacitor-rich-notifications';
import { RichNotifications } from '@capgo/capacitor-rich-notifications';
const { status } = await RichNotifications.requestPermission();
if (status !== 'granted') return;
import { RichNotifications } from '@capgo/capacitor-rich-notifications';
await RichNotifications.createChannel({
id: 'alerts',
name: 'Alerts',
importance: 'high',
});
import { RichNotifications } from '@capgo/capacitor-rich-notifications';
const { id } = await RichNotifications.display({
title: 'Hello',
body: 'Tap to open',
channelId: 'alerts',
});
  • リスナー: 画面がアンマウントされたらハンドルを削除します。
  • ネイティブ同期: 実行 bunx cap sync プラグインのアップグレード後。
  • 信頼できる情報源: 信頼 src/definitions.ts GitHub リポジトリ内。

プラットフォームのセットアップ

「プラットフォームのセットアップ」セクション
  • iOSの設定 カテゴリと割り込みレベルについて。
  • Androidの設定 を POST_NOTIFICATIONS、チャネル、および任意の正確なアラームまたはフォアグラウンドサービス権限。
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',
});
await RichNotifications.addListener('press', (event) => {
console.log(event.id, event.actionId, event.input);
});