ガイド
通知のチュートリアル
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__内でフォルダを検索してください。capacitor.config.*. - Capgo内で顧客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 ネイティブプッシュメッセージングを計画するには、Capacitor-notificationsと接続する @capgo/capacitor-notifications 実装の詳細については デバッグ トラブルシューティング @capgo/capacitor-updater 静的更新チェックのために Capgo Plugin Directory その他のネイティブプラグイン