Getting Started
설치 단계와 이 플러그인의 전체 마크다운 가이드를 포함한 설정 지시를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-notifications`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/notifications/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
@capgo/capacitor-notifications Capgo는 native iOS 및 Android 푸시 알림을 위한 첫 번째 파티 플러그인입니다. Capgo의 대시보드, 공개 API, 분석 엔진 장치 등록, 캠페인 통계, 배지 업데이트 및 무음 실시간 업데이트 검사에 빌드됩니다.
패키지는 현재 사설 프리뷰 상태입니다. Capgo는 npm 계정에 패키지 접근 권한을 활성화해야 하므로 설치 명령이 작동합니다.
요구 사항
제목 ‘요구 사항’- Capacitor 앱이 Capgo에 이미 추가되어 있습니다.
- Capgo 앱의 알림 탭에 접근할 수 있습니다.
- Capgo API 키가 백엔드 증명 인쇄와 API 전송에 대한 쓰기 접근 권한이 있습니다.
- iOS 및/또는 Android 플랫폼 푸시 권한이 앱에 있습니다.
@capgo/capacitor-updatersilent push update checks를 원한다면.
1. Capgo 플랫폼 자격 증명 구성
1. Capgo 플랫폼 인증 정보를 구성하십시오앱을 열고 Capgo으로 이동하십시오 通知.
지원하고자 하는 각 플랫폼에 대해 하나의 플랫폼 인증 정보 항목을 추가하십시오
- 안드로이드 - 앱 패키지 ID 및 안드로이드 푸시 프로젝트 메타데이터
- iOS - 번들 ID, 팀 ID, 키 ID 및 iOS 푸시 키 메타데이터와 일치하는
Capgo은 플랫폼이 구성된 것으로 표시하기 전에 API 워커에서 존재해야 하는 정확한 환경 시크릿 이름을 표시합니다. 대시보드는 메타데이터와 예상 시크릿 참조를 저장합니다. 개인 인증 자체는 워커 환경에서 유지됩니다.
For the fastest setup, run the Capgo CLI from your app project:
npx @capgo/cli@latest notifications setup com.example.appCapacitor 플러그인 설정을 저장하고 Capacitor 동기화를 실행하는 데 필요한 작은 도우미 파일을 생성하는 데 사용하는 명령어를 설치합니다. 새로운 앱에 사용할 경로입니다. 만약 모든 파일을 수동으로 연결해야 한다면 필요합니다.
수동 설치:
npm install @capgo/capacitor-notifications @capgo/capacitor-updaternpx cap syncsilent Capgo 업데이트 확인을 사용하지 않는다면 생략할 수 있습니다. @capgo/capacitor-updater.
3. 플러그인 설정
앱이 시작될 때 한 번만 플러그인을 설정합니다.클립보드에 복사
import { CapgoNotifications } from '@capgo/capacitor-notifications'
await CapgoNotifications.configure({ appId: 'com.example.app', autoUpdater: true, updateInstallMode: 'next',})사용 updateInstallMode: 'next' 업데이트를 다운로드하고 다음 재시작 또는 백그라운드 사이클에서 설치합니다. 사용 updateInstallMode: 'set' Capgo을 즉시 업데이트를 설치하고자 할 때만 사용합니다.
4. 신분증명 발급
‘4. 신분증명 발급’ 섹션Capgo API 키를 모바일 앱에 넣지 마십시오. 백엔드에서는 Capgo에서 사용자 인증이 성공한 후에 identityProof 터미널 창
curl -X POST 'https://api.capgo.app/notifications/recipients/proof' \ -H 'Content-Type: application/json' \ -H 'x-api-key: CAPGO_API_KEY' \ -d '{ "appId": "com.example.app", "externalId": "customer-user-123" }'__CAPGO_KEEP_1__와 함께 __CAPGO_KEEP_2__에서 identityProof 5. 장치 등록
‘5. 장치 등록’ 섹션
4. 신분증명 발급__CAPGO_KEEP_0__을 등록하기 전에 로그인한 고객 사용자를 확인하세요.
const registration = await CapgoNotifications.register({ externalId: 'customer-user-123', identityProof, tags: ['paid', 'beta'], attributes: { plan: 'team', locale: 'en-US', }, consent: true,})
console.log(registration.recipientKey, registration.deviceKey)__CAPGO_KEEP_0__ register 다시 호출할 때:
- 앱이 시작될 때.
- 네이티브 푸시 토큰이 변경될 때.
- 로그인한 사용자가 변경될 때.
- 태그, 속성, 또는 동의가 변경될 때.
- __CAPGO_KEEP_0__이 오랫동안 등록을 갱신하지 않았을 때.
6. 이벤트 리스너 추가
제목 ‘6. 이벤트 리스너 추가’앱이 시작될 때 리스너를 등록하여 프론트그라운드, 열린, 배경 이벤트가 자바스크립트로 표시되도록 합니다.
await CapgoNotifications.addListener('registrationChanged', () => { void CapgoNotifications.register({ externalId: currentUser.id, identityProof: currentUser.capgoNotificationProof, tags: currentUser.notificationTags, consent: currentUser.pushConsent, })})
await CapgoNotifications.addListener('notificationReceived', (notification) => { console.log('Notification received', notification)})
await CapgoNotifications.addListener('notificationOpened', (event) => { console.log('Notification opened', event.notification.id)})
await CapgoNotifications.addListener('backgroundNotification', async (event) => { try { console.log('Background notification', event.notification.data) } finally { await event.finish() }})__CAPGO_KEEP_0__ finish() __CAPGO_KEEP_1__
7. iOS 설정
7. iOS 설정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)}__CAPGO_KEEP_2__
npx cap sync iosiOS 장치의 실제 물리적 버전을 사용하여 배경 알림을 테스트하세요. 시뮬레이터는 UI 작업에 유용하지만 실제 배경 푸시 동작을 나타내지 않습니다.
8. 안드로이드 설정
8. 안드로이드 설정실행:
npx cap sync android그런 다음 확인:
- Capgo 에서 플랫폼 알림 설정에 사용된 패키지 ID와 앱 패키지 ID가 일치하는지 확인합니다.
- 안드로이드 13 이상의 알림 권한이 요청되기 전에 표시되는 알림을 기대하지 마세요.
- 앱은 브랜드와 일치하는 알림 아이콘과 채널 전략을 가지고 있습니다.
- 8. Android Setup
- Google Play 서비스가 있는 실제 장치 또는 에뮬레이터에서 테스트합니다.
앱이 시작될 때 기본 Android 채널을 생성합니다:
await CapgoNotifications.configure({ appId: 'com.example.app' })
await CapgoNotifications.register({ externalId: currentUser.id, identityProof: currentUser.capgoNotificationProof, consent: true,})Android 푸시 메시징 서비스를 선언하는 플러그인이며, 앱 백업, 데이터 추출, 네트워크 보안 및通知 아이콘 정책은 호스트 앱에서 관리합니다.
9. 테스트 알림을 보냅니다.
제목이 '9. 테스트 알림을 보냅니다.'인 섹션사용 通知 > 테스트 전송 Capgo에 복사하거나, 백엔드에서 API의 공개 버전을 호출하세요:
curl -X POST 'https://api.capgo.app/notifications/send' \ -H 'Content-Type: application/json' \ -H 'x-api-key: CAPGO_API_KEY' \ -d '{ "appId": "com.example.app", "target": { "externalId": "customer-user-123" }, "payload": { "title": "Hello from Capgo", "body": "This is a test notification.", "data": { "screen": "inbox" } } }'캠페인인 경우, 대시보드에서 생성하거나 호출하세요. /notifications/campaigns그런 다음 외부 ID, 태그, 세그먼트 또는 방송 청중에게 보냅니다.
10. 배지 설정
제목 '10. 배지 설정'await CapgoNotifications.setBadge(4)await CapgoNotifications.incrementBadge()await CapgoNotifications.clearBadge()백엔드에서:
curl -X POST 'https://api.capgo.app/notifications/badge' \ -H 'Content-Type: application/json' \ -H 'x-api-key: CAPGO_API_KEY' \ -d '{ "appId": "com.example.app", "target": { "externalId": "customer-user-123" }, "badge": 4 }'11. 무음 업데이트 확인
제목 '11. 무음 업데이트 확인'무음 업데이트 확인은 이 플러그인을 @capgo/capacitor-updater.
앱 내:
await CapgoNotifications.enableUpdaterIntegration({ enabled: true, installMode: 'next',})Capgo에서 활성화하십시오. 사용자에게 푸시 업데이트를 전송하십시오. 앱의 알림 설정에서 활성화한 후, API에서 업데이트를 확인하십시오.
curl -X POST 'https://api.capgo.app/notifications/update-check' \ -H 'Content-Type: application/json' \ -H 'x-api-key: CAPGO_API_KEY' \ -d '{ "appId": "com.example.app", "target": { "externalId": "customer-user-123" }, "installMode": "next" }'알림은 무음으로 설정되어 있으며, collapse ID를 사용하여 반복적인 업데이트 체크가 서로 대체될 수 있습니다.
유효성 검사 목록
유효성 검사 목록 섹션- Capgo에서 등록된 앱이 예상한 수신자 목록에 나타납니다.
externalId. - 권한이
granted권한이 허용되거나 사용자가 알림 권한을 수락한 경우 - __CAPGO_KEEP_0__
android또는 토큰 갱신 후에 발생합니다.ios. registrationChanged전면 테스트 로그- 通知 열기 로그
notificationReceived. - 대시보드 통계는 큐드되고 전송된 이벤트를 보여주고, 장치가 그들을 보고하면 받은/열린 이벤트를 보여줍니다.
notificationOpened. - silent update checks는
- 업데이터 통합
runUpdateCheckGetting Started에서 계속
Getting Started에서 계속
설정이 작동하지 않으면디버깅 앱 __CAPGO_KEEP_0__을 변경하기 전에 before changing app code. Most failures are caused by identity proof mismatch, platform credential setup, OS permission state, background throttling, or app/package ID mismatch.