メインコンテンツへスキップ
@capgo/capacitor-rich-notifications コミュニケーション オープンソース

リッチ通知 Capacitor プラグイン

Android のチャンネル、プログレスレイアウト、アクションボタン、スケジューリング、iOS の割り込みレベルに対応したローカル通知

インストール

bun add @capgo/capacitor-rich-notifications bunx cap sync
npm、pnpm、または yarn
  • npm install @capgo/capacitor-rich-notifications
  • pnpm add @capgo/capacitor-rich-notifications
  • yarn add @capgo/capacitor-rich-notifications

ガイド

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を指定して通知を1件キャンセルします。
  • 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 },
});

リファレンス全文

よくある質問

Rich Notifications プラグイン FAQ

Capacitor アプリに Rich Notifications プラグインをインストールするには?

"bun add @capgo/capacitor-rich-notifications"(または "npm install @capgo/capacitor-rich-notifications")を実行し、次に "bunx cap sync" を実行して、iOS と Android プロジェクトがネイティブ code を認識するようにします。アプリの code から "@capgo/capacitor-rich-notifications" をインポートしてください。

@capgo/capacitor-rich-notifications は React、Vue、Angular と互換性がありますか?

はい。Rich Notifications は Capacitor パッケージであるため、Ionic、React、Vue、Angular、Svelte、プレーン JavaScript を含む、Capacitor 内で動作するすべての Web フレームワークと互換性があります。

@capgo/capacitor-rich-notifications はどの Capacitor バージョンをサポートしていますか?

Capgo プラグインは Capacitor のメジャーバージョンに合わせています。使用している Capacitor のメジャーバージョンに一致するプラグインのメジャーバージョンを使ってください (例: Capacitor 8 ならプラグイン v8)。GitHub の README にある互換性テーブルに、メンテナンス中のバージョンが記載されています。

@capgo/capacitor-rich-notificationsは無料かつオープンソースですか?

はい。codeのソースコードはGitHubの https://github.com/Cap-go/capacitor-rich-notifications/ で公開されており、npmから無料でインストールできます。バグ報告やプルリクエストも歓迎しています。

App Storeの審査なしで、Rich Notificationsを使用しているcodeをアップデートできますか?

プラグインのインストールやアップグレードはネイティブの code を変更するため、新しいストアビルドが必要です。その後は、プラグインを呼び出す JavaScript、HTML、CSS の変更を Capgo Live Updates で即座に配信できます。

アプリの審査を待たずに Rich Notifications の変更をリリース

プラグインをストア用ビルドに組み込めば、Capgo live updates で JavaScript、HTML、CSS の変更を数分でユーザーに配信できます

Capgo から始める