# 为 Unity 设置角标

由于 Unity 插件不包含 PWNotificationExtensionManager 头文件，您必须执行几个额外步骤才能为您的 Unity 项目实现角标。


<Aside type="note">
要为 iOS 原生应用实现角标，请参阅 [设置角标](/zh/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="/cross-platform-frameworks-setting-up-badges-for-unity-1.webp" alt=""/>

### 3. 将 Pushwoosh.xcframework 添加到 NotificationService 扩展目标，如下所示：

1. 选择 **NotificationService** 扩展目标。
2. 前往 “**General**” 选项卡。
3. 找到 “**Framework and Libraries**” 并按 “**+**” 按钮。
4. 选择 **Pushwoosh.xcframework**。



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

### 4. 按如下方式更新 Notification Service Extension 代码：

```
#import "NotificationService.h"
#import "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
```

### 5. 为您的应用程序的每个目标添加 "App Groups Capability"

<img src="/cross-platform-frameworks-setting-up-badges-for-unity-2.webp" alt=""/>

<img src="/cross-platform-frameworks-setting-up-badges-for-unity-3.webp" alt="App Groups Capability"/>

<img src="/cross-platform-frameworks-setting-up-badges-for-unity-4.webp" alt="Info.plist"/>

### 6. 将 App Groups ID 添加到您应用程序每个目标的 info.plist 中

```
<key>PW_APP_GROUPS_NAME</key>
<string>group.com.example.demoapp_example</string>
```

## 与我们分享您的反馈

您的反馈有助于我们创造更好的体验，因此如果您在 SDK 集成过程中遇到任何问题，我们很乐意听取您的意见。如果您遇到任何困难，请随时[通过此表单](https://docs.google.com/forms/d/e/1FAIpQLSd\_0b8jwn-V\_JmoPLIxIFYbHACCQhrzidOZV3ELywoQPXRSxw/viewform)与我们分享您的想法。