การตั้งค่า Badges สำหรับ Cordova
เนื่องจากปลั๊กอิน Cordova ไม่มีเฮดเดอร์ PWNotificationExtensionManager คุณจึงต้องทำขั้นตอนเพิ่มเติมหลายอย่างเพื่อติดตั้ง Badges สำหรับโปรเจกต์ Cordova ของคุณ
สิ่งที่คุณต้องทำเพื่อตั้งค่า Badges มีดังนี้:
- สร้าง Notification Service Extension
- เพิ่มเฟรมเวิร์ก Pushwoosh
- เพิ่มความสามารถ App Groups
1. เพิ่ม Notification Service Extension (File -> New -> Target…)
Anchor link to
2. เลือก “Notification Service Extension”
Anchor link to
3. เพิ่ม Pushwoosh.xcframework ไปยัง target ของ NotificationService extension ดังนี้:
Anchor link to- เลือก target ของ NotificationService extension
- ไปที่แท็บ “General”
- ค้นหา ‘Framework and Libraries’ แล้วกดปุ่ม ’+’
- เลือก Pushwoosh.xcframework


4. อัปเดตโค้ดของ Notification Service Extension ดังนี้:
Anchor link to#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 ของแอปพลิเคชันของคุณ
Anchor link to


6. เพิ่ม App Groups ID ไปยังไฟล์ info.plist ของคุณสำหรับแต่ละ target ของแอปพลิเคชัน
Anchor link to<key>PW_APP_GROUPS_NAME</key><string>group.com.example.demoapp_example</string>
แบ่งปันความคิดเห็นของคุณกับเรา
Anchor link toความคิดเห็นของคุณช่วยให้เราสร้างประสบการณ์ที่ดีขึ้น เราจึงยินดีรับฟังความคิดเห็นของคุณหากคุณพบปัญหาระหว่างขั้นตอนการติดตั้ง SDK หากคุณประสบปัญหาใดๆ โปรดอย่าลังเลที่จะแบ่งปันความคิดเห็นของคุณกับเรา ผ่านแบบฟอร์มนี้