Skip to main content
플러그인으로 돌아가기
@capgo/capacitor-notifications
튜토리얼
@capgo/capacitor-notifications

알림

Capgo 다운로드/월

안내

알림에 대한 튜토리얼

capgo/capacitor-알림 사용

Capgo에서 native iOS 및 Android 푸시 알림을 보내기 위해 사용자 조회, 배지, 전면/열기 추적, 배경 콜백 및 무음 Capgo 실시간 업데이트 확인을 사용합니다.

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 백엔드에서 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 설정

켜기 푸시 알림 페이지/영역: Capgo 마케팅 웹사이트. 역할: 짧은 UI 레이블 또는 네비게이션 아이템. 메시지 키 `push_notifications` (푸시 알림). 그리고 페이지/영역: Capgo 마케팅 웹사이트. 역할: 짧은 UI 레이블 또는 네비게이션 아이템. Seen in: trust.astro 페이지. 메시지 키 `and` (그리고).

배경 모드 > 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)
}

안드로이드 설정

실행 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, and backgroundNotification.
  • 대시보드에서 테스트 알림을 보내세요.
  • 대기 중인, 전송된, 수신된, 열린 이벤트의 통계를 확인하세요.
  • 잠재 업데이트를 확인하기 위해 @capgo/capacitor-updater 설치되어야 하고 autoUpdater 활성화되어야 합니다.

전체 참조

Keep going from Using @capgo/capacitor-notifications

Capacitor-notifications를 사용 중이라면 capgo-capacitor 알림 __CAPGO_KEEP_0__/__CAPGO_KEEP_1__-알림을 사용하여 capgo/capacitor-알림 __CAPGO_KEEP_0__/__CAPGO_KEEP_1__-알림 구현에 대한 세부 정보 디버깅 트러블 슈팅 capgo/capacitor-업데이터 __CAPGO_KEEP_0__-업데이트를 위해 silent하게 확인하고 Capgo 플러그인 디렉토리 __CAPGO_KEEP_0__ 플러그인