# Flutter용 배지 설정하기

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

<img src="/flutter-setting-up-badges-for-flutter-1.webp" alt=""/>

<img src="/flutter-setting-up-badges-for-flutter-2.webp" alt=""/>

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

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

<Aside type="note">
아래 예시처럼 `target ‘Runner’ do` 뒤에 이 라인들을 추가할 수 있습니다:

```bash title="Podfile 예시"
target ‘Runner’ do
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
target ‘NotificationService’ do
  pod ‘PushwooshXCFramework’, ‘>=6.5.0’
end
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end
```
</Aside>

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

```
cd ios && pod install
```

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

<Aside type="caution">
프로젝트를 .xcproject 가 아닌 **.xcworkspace 를 통해** 여는지 확인하세요.
</Aside>

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

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

<img src="/flutter-setting-up-badges-for-flutter-3.webp" alt=""/>

<img src="/flutter-setting-up-badges-for-flutter-4.webp" alt=""/>

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

<img src="/flutter-setting-up-badges-for-flutter-5.webp" alt=""/>

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

```objective-c
#import “NotificationService.h”
#import &#x3C;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
```


## 피드백을 공유해주세요

여러분의 피드백은 더 나은 경험을 만드는 데 도움이 됩니다. SDK 통합 과정에서 문제가 발생하면 언제든지 알려주세요. 어려움을 겪으신다면 주저하지 마시고 [이 양식을 통해](https://docs.google.com/forms/d/e/1FAIpQLSd\_0b8jwn-V\_JmoPLIxIFYbHACCQhrzidOZV3ELywoQPXRSxw/viewform) 의견을 공유해주세요.