メインコンテンツにスキップ
@capgo/capacitor-notifications デバイスAPI オープンソース

通知 Capacitor プラグイン

Capgo を使用して、ユーザー検索、バッジ、統計、静音更新チェックを含む、ネイティブiOSおよびAndroidプッシュ通知を送信します。

インストール

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

ガイド

Capacitorで使用する方法の通知

@capgo/capacitor-notificationsを使用する

Capgoから、ユーザー検索、バッジ、フォアグラウンド/オープン追跡、バックグラウンドコールバック、静的Capgoライブアップデートチェックを含むネイティブiOSおよびAndroidプッシュ通知を送信できます。

プラグインはCapgoの通知パイプラインに設計されています。CapgoはPostgresにプラットフォーム認証情報メタデータとキャンペーンコントロールデータを格納し、Cloudflareアナリティクスエンジンにアクティブデバイス状態と配信イベントを書き込んでいます。

インストール

Capgo CLI を使用してガイド付きのセットアップを行ってください。

npx @capgo/cli@latest notifications setup com.example.app

手動インストール:

npm install @capgo/capacitor-notifications @capgo/capacitor-updater
npx cap sync

設定

import { CapgoNotifications } from '@capgo/capacitor-notifications'

await CapgoNotifications.configure({
  appId: 'com.example.app',
  autoUpdater: true,
  updateInstallMode: 'next',
})

署名ユーザーを登録する

mint identityProof バックエンドから POST /notifications/recipients/proof、あなたのログインが成功したら、デバイスを登録してください。

await CapgoNotifications.register({
  externalId: 'customer-user-123',
  identityProof,
  tags: ['paid'],
  attributes: { plan: 'team' },
  consent: true,
})

イベントをリスンする

await CapgoNotifications.addListener('notificationReceived', (notification) => {
  console.log('Received', notification)
})

await CapgoNotifications.addListener('notificationOpened', (event) => {
  console.log('Opened', event.notification.id)
})

await CapgoNotifications.addListener('backgroundNotification', async (event) => {
  try {
    console.log('Background payload', event.notification.data)
  } finally {
    await event.finish()
  }
})

iOS セットアップ

有効 プッシュ通知 と バックグラウンドモード > Remote通知 Xcodeで。

Remote通知を ios/App/App/AppDelegate.swift:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    NotificationCenter.default.post(name: Notification.Name("CapgoNotificationsRemoteNotification"), object: userInfo)
    completionHandler(.newData)
}

Androidセットアップ

実行 npx cap sync androidAndroidプラットフォームの資格情報をCapgoに設定し、Android 13以降で通知許可を要求し、Google Playサービスを搭載したデバイスまたはエミュレータでテストしてください。

CapgoのUIを比較すると、ビルドステップでは、

  • 実行 npx @capgo/cli@latest notifications setup com.example.app CapgoのUIを比較すると、インストールステップでは、 capacitor.config.*.
  • 受信者を検索するには、外部顧客IDでCapgoを検索してください。
  • デバッグチェックリスト android or ios および、許可が与えられている。
  • 一時的なリスナーを追加します。 registrationChanged, notificationReceived, notificationOpened, および backgroundNotification.
  • ダッシュボードからテスト通知を送信します。
  • キューされた、送信された、受信された、そして開封されたイベントの統計を確認します。
  • 静的なアップデートチェックの場合、 @capgo/capacitor-updater がインストールされているかどうかを確認し、 autoUpdater 機能が有効になっています。

フルリファレンス

Using @capgo/capacitor-notifications

あなたが使用している Using @capgo/capacitor-notifications native push メッセージングの計画に使用している場合 @capgo/capacitor-notifications 実装の詳細 デバッグ トラブルシューティング @capgo/capacitor-アップデーター 静的更新チェックのために Capgo プラグインディレクトリ 他のネイティブ プラグインについて。

よくある質問

通知プラグインのFAQ

Capacitor Notifications プラグインを Capacitor アプリにインストールする方法は何ですか。

Run "bun add @capgo/capacitor-notifications" (or "npm install @capgo/capacitor-notifications"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-notifications" in your app code.

@capgo/capacitor-notificationsは、React、Vue、Angularとどのように動作するか?

Yes. Notifications is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-notifications support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

@capgo/capacitor-通知は無料でオープンソースですか?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capgo/tree/main/packages/capacitor-notifications/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses Notifications without an App Store review?

codeを変更すると、ネイティブアプリケーションを再構築する必要があります。 その後、JavaScript、HTML、CSSの変更がプラグインを呼び出すことができるので、Capgoライブアップデートで即時配信できます。

アプリレビューの待ちなしで通知の変更を配信

プラグインがストアのビルドに含まれると、Capgo ライブ アップデートは、JavaScript、HTML、CSS の変更をユーザーに 1 分間で反映します。

Capgo で始めましょう