# Настройка бейджей для Flutter

1. Откройте ваш iOS-проект, расположенный в **your_project/ios/Runner.xcworkspace**, и создайте **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**) и добавьте зависимость **PushwooshXCFramework** для NotificationServiceExtensionTarget:

```
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">
Убедитесь, что вы открываете проект **через .xcworkspace**, а не через .xcproject.
</Aside>

5. Убедитесь, что ваш **Deployment target совпадает с target в Runner**; в противном случае вы можете столкнуться с проблемой при сборке приложения (например, если вы укажете iOS 10.0 в Runner и iOS 15.5 в NotificationService target).

6. Добавьте **возможность App Groups** к target'ам Runner и NotificationService и добавьте новую группу с одинаковым именем для обоих target'ов:

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

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

7. Добавьте флаг **PW_APP_GROUPS_NAME** в info.plist для target'ов Runner и NotificationService, указав имя группы в качестве его строкового значения:

<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).