# การตั้งค่า Badges สำหรับ Unity

เนื่องจากปลั๊กอิน Unity ไม่มีเฮดเดอร์ PWNotificationExtensionManager คุณจึงต้องทำขั้นตอนเพิ่มเติมหลายขั้นตอนเพื่อใช้งาน Badges สำหรับโปรเจกต์ Unity ของคุณ


<Aside type="note">
หากต้องการใช้งาน Badges สำหรับแอป iOS Native โปรดดูที่คู่มือ [การตั้งค่า Badges](/th/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 ไปยัง target ของ NotificationService extension ดังนี้:

1. เลือก target ของ **NotificationService** extension
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" สำหรับแต่ละ target ของแอปพลิเคชันของคุณ

<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 ของคุณสำหรับแต่ละ target ของแอปพลิเคชัน

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