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

Поскольку плагин React Native не содержит заголовок PWNotificationExtensionManager, вам необходимо выполнить несколько дополнительных шагов для реализации бейджей в вашем проекте React Native.


<Aside type="note">
Для реализации бейджей в нативном iOS-приложении, пожалуйста, обратитесь к руководству [Настройка бейджей](/ru/developer/pushwoosh-sdk/ios-sdk/setting-up-badges/).
</Aside>

#### 1. Добавьте Notification Service Extension (File -> New -> Target...)

<img src="/shared-7.webp" alt=""/>

#### 2. Выберите "Notification Service Extension"

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

#### 3. Обновите код Notification Service Extension следующим образом:

```
#import "NotificationService.h"
#import <Pushwoosh/PWNotificationExtensionManager.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 * _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
```

<Aside type="note">
Замените имя расширения, используемое в строке `#import "NotificationService.h"`, на имя вашего расширения.
</Aside>

#### 4. Свяжите зависимости с целью (target)

React Native не связывает автоматически все необходимые зависимости с целью (target), созданной вручную, поэтому вам следует обновить **Build Phases** цели и предоставить необходимую информацию:

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

Просто нажмите на знак **+** под **Compile Sources** и **Link Binary With Libraries** и найдите необходимые библиотеки/фреймворки.

#### 5. Добавьте возможность **App Groups** для обеих целей в Xcode и установите одну и ту же группу **как для приложения, так и для расширения**:

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

#### 6. Добавьте ключ **PW\_APP\_GROUPS\_NAME** в info.plist **обеих** целей. Значение — это имя вашей группы приложений:

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