iOS SDK 고급 통합 가이드
이 섹션에서는 Pushwoosh iOS SDK 의 고급 통합에 대한 정보를 제공합니다.
백그라운드 모드
Anchor link to이 기능을 활성화하려면 프로젝트에 백그라운드 모드를 추가해야 합니다.
백그라운드 모드 활성화 단계
Anchor link to- Xcode 에서 프로젝트를 열고 프로젝트 탐색기에서 선택합니다.
- 왼쪽 패널에서 앱 타겟을 선택합니다.
- 서명 및 기능 탭으로 이동합니다.
- 왼쪽 상단 모서리에 있는 + Capability 버튼을 클릭합니다.
- 목록에서 Background Modes 를 검색하여 선택합니다.
- Background Modes 섹션에서 Remote notifications 확인란을 선택하여 활성화합니다.
완료되면 앱은 백그라운드에서 실행되는 동안 무음 푸시 알림을 포함한 푸시 알림을 처리할 수 있습니다.
포그라운드 모드
Anchor link to기본적으로 Pushwoosh iOS SDK 는 앱이 포그라운드에서 실행될 때 알림 배너를 표시합니다.
코드 (예: AppDelegate 내)에서 다음 부울 플래그를 설정하여 이 동작을 제어할 수 있습니다.
// Set false to disable foreground notifications, true to enable itPushwoosh.sharedInstance().showPushnotificationAlert = true// Set 0 to disable foreground notifications, 1 to enable it[[Pushwoosh sharedInstance] setShowPushnotificationAlert:0];로그 레벨
Anchor link toPushwoosh iOS SDK 는 다음 로깅 레벨을 지원합니다:
NONE- SDK 에서 로그 없음.ERROR- 콘솔에 오류 메시지만 표시합니다.WARNING- 오류 외에 경고를 표시합니다.INFO- 정보 메시지를 포함합니다 (기본 설정).DEBUG- 자세한 디버그 정보를 포함합니다.
기본적으로 로깅 레벨은 INFO 로 설정되어 SDK 가 개발자 콘솔을 복잡하게 만들지 않고 관련 정보를 제공하도록 합니다.
로깅 레벨을 수정하려면 앱의 Info.plist 파일에서 Pushwoosh_LOG_LEVEL 키를 업데이트하십시오:
<key>Pushwoosh_LOG_LEVEL</key><string>YOUR_LOG_LEVEL</string>또는 아래 코드 스니펫을 사용하여 로그 레벨을 변경할 수 있습니다:
Pushwoosh.Debug.setLogLevel(.PW_LL_DEBUG)YOUR_LOG_LEVEL 을 원하는 레벨 (예: DEBUG 또는 ERROR)로 바꿉니다.
사용자 지정 UNNotificationCenterDelegate
Anchor link to자신만의 UNNotificationCenterDelegate 를 사용하려는 경우 (예: 로컬 알림용), Pushwoosh SDK 에 알려 적절하게 동작하도록 해야 합니다. Pushwoosh 인스턴스의 notificationCenterDelegateProxy 속성을 사용하여 이를 수행할 수 있습니다:
Pushwoosh.sharedInstance()?.notificationCenterDelegateProxy.add(my_delegate)[Pushwoosh.sharedInstance.notificationCenterDelegateProxy addNotificationCenterDelegate:my_delegate];그런 다음, 델리게이트에서 UNNotificationCenterDelegate 메서드를 구현합니다:
func userNotificationCenter( _ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { if (!PWMessage.isPushwooshMessage(notification.request.content.userInfo)) { // Handle your notification completionHandler(UNNotificationPresentationOptions.alert) }}
func userNotificationCenter( _ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { if (!PWMessage.isPushwooshMessage(response.notification.request.content.userInfo)) { // Handle your notification completionHandler() }}- (void)userNotificationCenter:(UNNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { if (![PWMessage isPushwooshMessage:notification.request.content.userInfo]) { // Handle your message completionHandler(UNNotificationPresentationOptionAlert); }}
- (void)userNotificationCenter:(UNNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { if (![PWMessage.isPushwooshMessage:response.notification.request.content.userInfo]) { // Handle your message completionHandler(); }}Pushwoosh 지연 초기화
Anchor link toPushwoosh_LAZY_INITIALIZATION 플래그는 애플리케이션 시작 시 Pushwoosh SDK 의 자동 초기화를 방지합니다. 이를 통해 Pushwoosh SDK 서비스가 시작되는 시점을 더 잘 제어할 수 있습니다.
이 플래그가 활성화되면 Pushwoosh SDK 메서드가 명시적으로 호출될 때까지 Pushwoosh SDK 는 서비스를 시작하지 않습니다.
Info.plist 에 다음 항목을 추가합니다:
<key>Pushwoosh_LAZY_INITIALIZATION</key><true/>사용 사례
-
제어된 SDK 초기화 – Pushwoosh_LAZY_INITIALIZATION 플래그는 Pushwoosh SDK 시작을 지연시켜 푸시 서비스가 활성화되는 시점을 더 잘 제어할 수 있도록 합니다.
-
지연된 푸시 활성화 – 일부 애플리케이션에서는 특정 조건에서만 푸시 알림을 초기화해야 합니다. 이 플래그를 활성화하면 명시적으로 요청될 때만 Pushwoosh SDK 가 시작됩니다.
-
사용자별 푸시 구성 – 일부 애플리케이션은 사용자 기본 설정 또는 계정 설정에 따라 푸시 알림 설정을 사용자 지정해야 할 수 있습니다. 지연 초기화를 사용하면 적절한 구성이 결정된 후에만 Pushwoosh SDK 가 시작됩니다.
Info.plist 속성 전체 목록
Anchor link to| 속성 | 설명 | 가능한 값 |
|---|---|---|
Pushwoosh_APPID | 프로덕션 빌드용 Pushwoosh 애플리케이션 ID 를 설정합니다. | XXXXX-XXXXX 유형: String |
Pushwoosh_APPID_Dev | 개발 빌드용 Pushwoosh 애플리케이션 ID 를 설정합니다. | XXXXX-XXXXX 유형: String |
Pushwoosh_SHOW_ALERT | 알림 포그라운드 알림을 표시합니다. | YES (기본값) / NO 유형: Boolean |
Pushwoosh_ALERT_TYPE | 알림 알림 스타일을 설정합니다. | BANNER (기본값) / ALERT / NONE 유형: String |
Pushwoosh_BASEURL | Pushwoosh 서버 기본 URL 을 재정의합니다. | https://cp.pushwoosh.com/json/1.3/ (기본값) 유형: String |
Pushwoosh_AUTO_ACCEPT_DEEP_LINK_FOR_SILENT_PUSH | YES 인 경우, 무음 푸시에서 수신된 딥 링크가 자동으로 처리됩니다. | YES (기본값) / NO 유형: Boolean |
Pushwoosh_ALLOW_SERVER_COMMUNICATION | SDK 가 Pushwoosh 서버로 네트워크 요청을 보내도록 허용합니다. | YES (기본값) / NO 유형: Boolean |
Pushwoosh_ALLOW_COLLECTING_DEVICE_DATA | SDK 가 장치 데이터 (OS 버전, 로케일 및 모델)를 수집하여 서버로 보내도록 허용합니다. | YES (기본값) / NO 유형: Boolean |
Pushwoosh_ALLOW_COLLECTING_DEVICE_OS_VERSION | SDK 가 장치의 OS 버전을 수집하여 서버로 보내도록 허용합니다. | YES (기본값) / NO 유형: Boolean |
Pushwoosh_ALLOW_COLLECTING_DEVICE_LOCALE | SDK 가 장치 로케일을 수집하여 서버로 보내도록 허용합니다. | YES (기본값) / NO 유형: Boolean |
Pushwoosh_ALLOW_COLLECTING_DEVICE_MODEL | SDK 가 장치 모델을 수집하여 서버로 보내도록 허용합니다. | YES (기본값) / NO 유형: Boolean |
Pushwoosh_LOG_LEVEL | Pushwoosh SDK 로깅 레벨. 자세한 내용은 로그 레벨 제어를 참조하십시오. | NONE / ERROR / WARNING / INFO (기본값) / DEBUG / VERBOSE 유형: String |
Pushwoosh_PURCHASE_TRACKING_ENABLED | SDK 가 인앱 구매를 추적하도록 허용합니다. Customer Journey Builder 에 필요합니다. | YES / NO (기본값) 유형: Boolean |