본문 바로가기
@capgo/capacitor-notifications Device API 오픈 소스

알림 Capacitor 플러그인

Capgo에서 사용자 조회, 배지, 통계, silent update 확인 기능을 갖춘 iOS 및 Android 네이티브 푸시 알림을 보내세요

설치

bun add @capgo/capacitor-notifications bunx cap sync
npm, pnpm 또는 yarn
  • npm install @capgo/capacitor-notifications
  • pnpm add @capgo/capacitor-notifications
  • yarn add @capgo/capacitor-notifications

가이드

Capacitor에서 Notifications 사용 방법

@capgo/capacitor-notifications 사용하기

Capgo를 통해 사용자 조회, 배지, 포그라운드/오픈 트래킹, 백그라운드 콜백, 그리고 silent Capgo live-update 체크를 포함한 네이티브 iOS 및 Android 푸시 알림을 전송하세요.

이 플러그인은 Capgo 알림 파이프라인에 최적화되어 설계되었습니다. Capgo는 플랫폼 자격 증명 메타데이터와 캠페인 제어 데이터를 Postgres에 저장하며, 활성 디바이스 상태 및 전송 이벤트는 Cloudflare Analytics Engine에 기록됩니다.

설치

가이드 설정에는 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',
})

서명된 사용자 등록

발급 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 Modes > 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 android, Capgo에서 Android 플랫폼 인증 정보를 설정하고, Android 13+에서 알림 권한을 요청한 뒤, Google Play services가 포함된 기기나 에뮬레이터에서 테스트하세요.

디버깅 체크리스트

  • 실행 npx @capgo/cli@latest notifications setup com.example.app 다음이 포함된 폴더에서 capacitor.config.*.
  • Capgo에서 외부 고객 ID로 수신자를 검색하세요.
  • 기기에 플랫폼이 있는지 확인하세요 android 또는 ios 및 권한이 허용되었습니다.
  • 다음 항목에 대한 임시 리스너 추가: registrationChanged, notificationReceived, notificationOpened, 그리고 backgroundNotification.
  • 대시보드에서 테스트 알림을 보내보세요.
  • 대기, 전송, 수신 및 열람 이벤트 통계를 확인하세요.
  • Silent update 체크를 위해 다음을 확인하세요: @capgo/capacitor-updater 가 설치되어 있는지, autoUpdater 부분 전사 업데이트를 수신합니다.

전체 레퍼런스

@capgo/capacitor-notifications 사용법 계속 보기

사용 중이라면 @capgo/capacitor-notifications 사용하기 네이티브 푸시 메시징을 계획하고, 다음을 연결하려면 @capgo/capacitor-notifications 구현 세부 사항은, 디버깅 문제 해결은, @capgo/capacitor-updater Silent Update 체크는, Capgo 플러그인 디렉토리 다른 native plugin용입니다.

자주 묻는 질문

Notifications 플러그인 FAQ

Capacitor 앱에 Notifications 플러그인을 어떻게 설치하나요?

"bun add @capgo/capacitor-notifications" (또는 "npm install @capgo/capacitor-notifications")를 실행한 다음, "bunx cap sync"를 실행하여 iOS 및 Android 프로젝트에 네이티브 code가 반영되도록 하세요. 그 후 앱의 code에서 "@capgo/capacitor-notifications"를 통해 import 하세요.

@capgo/capacitor-notifications가 React, Vue, Angular와 호환되나요?

네. Notifications는 Capacitor 패키지이므로, Ionic, React, Vue, Angular, Svelte 및 일반 JavaScript를 포함하여 Capacitor 내에서 실행되는 모든 웹 프레임워크와 호환됩니다.

@capgo/capacitor-notifications은 어떤 Capacitor 버전을 지원하나요?

Capgo 플러그인은 Capacitor의 메이저 버전을 따릅니다. 사용 중인 Capacitor 메이저 버전과 일치하는 플러그인 메이저 버전을 사용하세요 (예: Capacitor 8에는 플러그인 v8). 유지 관리되는 버전은 GitHub README의 호환성 표에서 확인할 수 있습니다.

@capgo/capacitor-notifications는 무료이며 오픈 소스인가요?

네. code 소스 코드는 GitHub의 https://github.com/Cap-go/capgo/tree/main/packages/capacitor-notifications/ 에 공개되어 있으며, npm에서 무료로 설치할 수 있습니다. 버그 리포트와 pull request를 환영합니다.

App Store 심사 없이 Notifications를 사용하는 code를 업데이트할 수 있나요?

플러그인을 설치하거나 업그레이드하면 네이티브 code가 변경되므로 새로운 스토어 빌드가 필요합니다. 그 이후에는 플러그인을 호출하는 JavaScript, HTML, CSS 변경 사항을 Capgo live updates로 즉시 배포할 수 있습니다.

앱 심사 대기 없이 Notification 변경 사항을 즉시 배포하세요

스토어 빌드에 플러그인이 포함되면, Capgo live updates로 JavaScript, HTML, CSS 변경 사항을 몇 분 만에 사용자에게 푸시할 수 있습니다.

Capgo로 시작하기