콘텐츠로 건너뛰기

Flutter용 배지 설정하기

1. your_project/ios/Runner.xcworkspace에 있는 iOS 프로젝트를 열고 NotificationServiceExtension을 생성합니다:

2. Podfile(your_project/ios/Podfile에 위치)을 열고 NotificationServiceExtensionTarget에 PushwooshXCFramework 종속성을 추가합니다:

target ‘NotificationService’ do
pod ‘PushwooshXCFramework’, ‘>=6.5.0’
end

3. 터미널을 통해 pod를 설치합니다:

cd ios && pod install

4. Xcode 프로젝트를 닫았다가 다시 엽니다.

5. Deployment target이 Runner target의 것과 일치하는지 확인하세요. 그렇지 않으면 앱을 빌드할 때 문제가 발생할 수 있습니다 (예: Runner에서 iOS 10.0을 지정하고 NotificationService target에서 iOS 15.5를 지정하는 경우).

6. Runner와 NotificationService target 모두에 App Groups capability를 추가하고, 두 target에 동일한 이름으로 새 그룹을 추가합니다:

7. Runner와 NotificationService target 모두에 그룹 이름을 문자열 값으로 하는 PW_APP_GROUPS_NAME info.plist 플래그를 추가합니다:

8. NotificationService.m으로 이동하여 코드를 다음으로 교체합니다:

#import “NotificationService.h”
#import <Pushwoosh/PWNotificationExtensionManager.h>
@interface NotificationService ()
<strong>@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
</strong>@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@end
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
[[PWNotificationExtensionManager sharedManager] handleNotificationRequest:request contentHandler:contentHandler];
}
- (void)serviceExtensionTimeWillExpire {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your “best attempt” at modified content, otherwise the original push payload will be used.
self.contentHandler(self.bestAttemptContent);
}
@end

이것으로 끝입니다!

피드백을 공유해주세요

Anchor link to

여러분의 피드백은 더 나은 경험을 만드는 데 도움이 됩니다. SDK 통합 과정에서 문제가 발생하면 언제든지 알려주시기 바랍니다. 어려움이 있으시면 주저하지 마시고 이 양식을 통해 의견을 공유해주세요.