메인 콘텐츠로 건너뛰기
플러그인으로 돌아가기
@capgo/capacitor-notifications
튜토리얼
@capgo/capacitor-notifications

알림

iOS 및 Android에서 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 설정

켜기 푸시 알림 Background 모드 > Remote notifications Xcode에서 원격 알림을 전달

Capacitor 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)
}

안드로이드 설정

실행 npx cap sync android안드로이드 플랫폼 인증 정보를 Capgo 에서 설정하고, 안드로이드 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 활성화되어야 합니다.

전체 참조

Using @capgo/capacitor-notifications에서 계속하세요.

Capgo를 사용 중이라면 Using @capgo/capacitor-notifications 자연스러운 푸시 메시징을 계획하고 @capgo/capacitor-notifications implementation 세부 정보를 위해 Debugging 문제 해결을 위해 @capgo/capacitor-updater silent 업데이트 확인을 위해, Capgo Plugin Directory 기타 네이티브 플러그인