콘텐츠로 건너뛰기

Flutter용 배지 설정하기

  1. your_project/ios/Runner.xcworkspace 에 있는 iOS 프로젝트를 열고 NotificationServiceExtension 을 생성합니다:
  1. Podfile(your_project/ios/Podfile 에 위치)을 열고 NotificationServiceExtensionTarget 에 PushwooshXCFramework 종속성을 추가합니다:
target ‘NotificationService’ do
pod ‘PushwooshXCFramework’, ‘>=6.5.0’
end
  1. 터미널을 통해 pod을 설치합니다:
cd ios && pod install
  1. Xcode 프로젝트를 닫았다가 다시 엽니다.
  1. Deployment targetRunner target 의 것과 일치하는지 확인하세요. 그렇지 않으면 앱을 빌드할 때 문제가 발생할 수 있습니다 (예: Runner 에서는 iOS 10.0 을, NotificationService target 에서는 iOS 15.5 를 지정하는 경우).

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

  1. Runner 와 NotificationService target 모두에 그룹 이름을 문자열 값으로 하는 PW_APP_GROUPS_NAME info.plist 플래그를 추가합니다:
  1. 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 통합 과정에서 문제가 발생하면 언제든지 알려주세요. 어려움을 겪으신다면 주저하지 마시고 이 양식을 통해 의견을 공유해주세요.