iOS 푸시 메시지 이미지 첨부
지원 SDK 버전React Native SDK
3.26.0
버전 이상
iOS 앱에서 이미지를 포함한 푸시 메시지를 보여주기 위해서는 Notification Service Extension을 추가하여 아래의 설정을 완료합니다.
iOS Rich Push Notification 에 대한 자세한 사항은 Rich Push Notification 에서 확인 가능합니다.
1. 앱에 Notification Service Extension 추가
Xcode로 /ios/{APP_NAME}.xcworkspace
파일을 열어 프로젝트를 연 후 프로젝트 상단 File > New > Target...
탭을 선택하여 아래와 같이 Notification Service Extension
을 선택합니다.

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

CocoaPods 설정
Podfile
에 앞서 추가한 Extension
에 핵클 종속성을 추가해야 합니다.
아래와 같이 Hackle
종속성을 추가합니다.
target 'NotificationServiceExtension' do
pod 'Hackle'
end
2. Minimum Deployment 설정
최소 지원 버전이 앱과 extension이 다를 경우, 앱 버전에 따라 이미지가 표시되지 않을 수 있습니다.
ex) App 최소 지원 버전이 iOS 15, Extension 최소 지원 버전이 iOS 18인 경우
- iOS 15 이상, iOS 18 미만 버전은 이미지가 표시되지 않습니다.
- iOS 18 이상 버전은 이미지가 표시됩니다.
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)
}
}
}
#import <UserNotifications/UserNotifications.h>
@import Hackle;
@interface NotificationService : UNNotificationServiceExtension
@end
#import "NotificationService.h"
@interface NotificationService ()
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@end
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request
withContentHandler:(void (^)(UNNotificationContent *))contentHandler {
self.defaultNotificationContent = request.content;
self.contentHandler = contentHandler;
if ([Hackle handleRichNotificationWithRequest:request contentHandler:contentHandler]) {
return;
}
contentHandler(request.content);
}
- (void)serviceExtensionTimeWillExpire {
self.contentHandler(self.bestAttemptContent);
}
@end
Updated about 2 hours ago