Skip to content

Setting up badges for Unity

Since the Unity plugin does not contain the PWNotificationExtensionManager header, you have to perform several additional steps to implement Badges for your Unity project.

1. Add Notification Service Extension (File -> New -> Target…)

Anchor link to

2. Select the “Notification Service Extension”

Anchor link to

3. Add Pushwoosh.xcframework to NotificationService extension target as follows:

Anchor link to
  1. Choose NotificationService extension target.
  2. Go to the “General” tab.
  3. Find ‘Framework and Libraries’ and press ’+’ button.
  4. Select Pushwoosh.xcframework.

4. Update the Notification Service Extension code as follows:

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. Add the “App Groups Capability” for each target of your application

Anchor link to
App Groups CapabilityInfo.plist

6. Add the App Groups ID to your info.plist for each target of your application

Anchor link to
<key>PW_APP_GROUPS_NAME</key>
<string>group.com.example.demoapp_example</string>

Share your feedback with us

Anchor link to

Your feedback helps us create a better experience, so we would love to hear from you if you have any issues during the SDK integration process. If you face any difficulties, please do not hesitate to share your thoughts with us via this form.