설명서
Capacitor에서 알림을 사용하는 방법
@capgo/capacitor-notifications을 사용하는 방법
Capgo에서 사용자 확인, 배지, 전면/열기 추적, 배경 콜백 및 무음 Capgo 라이브 업데이트 확인을 지원하는 iOS 및 Android 네이티브 푸시 알림을 보내세요.
플러그인은 Capgo 알림 PIPELINE을 위한 것입니다. 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 백엔드에서 __CAPGO_KEEP_0__를 생성한 후 로그인 성공 후 장치 등록 POST /notifications/recipients/proof이벤트를 수신
await CapgoNotifications.register({
externalId: 'customer-user-123',
identityProof,
tags: ['paid'],
attributes: { plan: 'team' },
consent: true,
})
iOS 설정
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()
}
})
알림 활성화
푸시 알림 그리고 and 배경 모드 > Remote notifications Xcode에서
Remote notifications을 전달하세요 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 android안드로이드 플랫폼 인증 정보를 Capgo 에서 설정하고, 안드로이드 13 이상에서 알림 권한을 요청하고, Google Play 서비스가 있는 디바이스 또는 에뮬레이터에서 테스트하세요.
Xcode에서 Run을 클릭하고, Android 플랫폼 인증 정보를 __CAPGO_KEEP_0__에 구성하고, Android 13 이상에서 알림 권한을 요청하고, Google Play 서비스가 있는 기기 또는 에뮬레이터에서 테스트하세요.
- 실행
npx @capgo/cli@latest notifications setup com.example.app디버깅 체크리스트capacitor.config.*. - Capgo 폴더 안에 있는
- 받는 사람을 __CAPGO_KEEP_0__에서 외부 고객 ID로 검색하세요.
androidorios그런 경우 허가가 주어집니다. - 임시 리스너를 추가합니다.
registrationChanged,notificationReceived,notificationOpened, 그리고backgroundNotification. - 대시보드에서 테스트 알림을 보내십시오.
- 대기 중인, 전송된, 수신된, 그리고 열린 이벤트의 통계를 확인하십시오.
- silent 업데이트 확인을 위해
@capgo/capacitor-updater설치되어 있으며autoUpdater전체 참조
문서: /docs/plugins/notifications/
- 디버깅: /docs/plugins/notifications/debugging/
- 원본:
- Source: https://github.com/Cap-go/capgo/tree/main/packages/capacitor-notifications/
Using @capgo/capacitor-notifications
만약 사용 중이라면 Using @capgo/capacitor-notifications @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-notifications과 연결하여 @capgo/capacitor-알림 Debugging troubleshooting @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-updater @capgo/capacitor-업데이터 __CAPGO_KEEP_0__ 플러그인 디렉토리 Capgo 다른 네이티브 플러그인에 대해.