For the complete documentation index, see llms.txt. This page is also available as Markdown.

푸시메시지 이미지 첨부

iOS SDK 2.53.0 버전 이상에서 지원하는 기능입니다.

iOS 앱에서 이미지를 포함한 푸시 메시지를 보여주기 위해서는 Notification Service Extension을 추가하여 아래의 설정을 완료합니다.

iOS Rich Push Notification 에 대한 자세한 사항은 Rich Push Notification 에서 확인 가능합니다.

1

앱에 Notification Service Extension 추가

Xcode 프로젝트 상단 File > New > Target... 탭을 선택하여 아래와 같이 Notification Service Extension을 선택합니다.

알맞은 이름을 입력 후 Finish를 눌러주세요.

Swift Package Manager를 이용해 핵클 SDK를 추가한 경우 앞서 추가한 ExtensionHackle 프레임워크를 추가합니다.

2

Minimum Deployment 설정

Notification Service Extension은 앱과 별도로 최소 지원버전을 명시해야 합니다.

Minimum Deployment를 앱과 동일하게 설정하는 것을 추천합니다.

3

핵클 SDK와 연동하기

푸시 메시지에 이미지 추가

푸시 이미지 처리를 위해 didReceive 함수에서 handleRichNotification 함수를 추가합니다.

import UserNotifications
import Hackle

class NotificationService: UNNotificationServiceExtension {

    var defaultNotificationContent: UNNotificationContent?
    var contentHandler: ((UNNotificationContent) -> Void)?

    override func didReceive(
      _ request: UNNotificationRequest,
      withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void
    ) {
        self.defaultNotificationContent = request.content
        self.contentHandler = contentHandler

        if Hackle.handleRichNotification(request: request, contentHandler: contentHandler) {
            return
        }

        contentHandler(request.content)
    }

    override func serviceExtensionTimeWillExpire() {
      if let contentHandler = contentHandler,
         let defaultNotificationContent = defaultNotificationContent {
            contentHandler(defaultNotificationContent)
        }
    }
}

마지막 업데이트