ガイド
通知のチュートリアル
Using @capgo/capacitor-notifications
Send native iOS and Android push notifications from Capgo with user lookup, badges, foreground/open tracking, background callbacks, and silent Capgo live-update checks.
The plugin is built for the Capgo notification pipeline. Capgo stores platform credential metadata and campaign control data in Postgres, while active device state and delivery events are written to Cloudflare Analytics Engine.
インストール
Use the Capgo CLI for a guided setup:
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 notifications Xcodeで
リモート通知を転送 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 サービスを備えたデバイスまたはエミュレータでテストしてください。
デバッグ チェックリスト
- 実行
npx @capgo/cli@latest notifications setup com.example.app__CAPGO_KEEP_0__ 内の受信者を外部顧客 ID で検索します。capacitor.config.*. - Search the recipient in Capgo by external customer ID.
- または
androidデバイスがプラットフォームを確認していることを確認します。iosまたは - 一時リスナーを追加します。
registrationChanged,notificationReceived,notificationOpened、backgroundNotification. - ダッシュボードからテスト通知を送信します。
- キュー、送信、受信、開封イベントの統計を確認します。
- 静的な更新チェックの場合、
@capgo/capacitor-updaterインストールされているかどうかを確認し、autoUpdater有効になっているかどうかを確認します。
フル リファレンス
- ドキュメント: /docs/plugins/notifications/
- デバッグ: /docs/plugins/notifications/debugging/
- ソース: https://github.com/Cap-go/capgo/tree/main/packages/capacitor-notifications/
Keep going from Using @capgo/capacitor-notifications
Capacitor-notificationsを使用している場合 Using @capgo/capacitor-notifications __CAPGO_KEEP_0__/__CAPGO_KEEP_1__-通知 capgo/capacitor-通知 __CAPGO_KEEP_0__/__CAPGO_KEEP_1__-通知の実装詳細 デバッグ トラブルシューティング @capgo/capacitor-updater __CAPGO_KEEP_0__ プラグインディレクトリ Capgo Plugin Directory フッター