Setting up Badges for Cordova
This guide describes the process of implementing Badges for Pushwoosh Cordova plugin
Since the Cordova plugin does not contain the PWNotificationExtensionManager header, you have to perform several additional steps to implement Badges for your Cordova project.
That's what you need for setting Badges up:
To implement badges for iOS Native app, please refer to the Setting up Badges guide..

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

2. Select the "Notification Service Extension"

3. Add the PWNotificationExtensionManager.h.

To do that, you will need to modify Pushwoosh plugin's plugin.xml with the following line before adding the iOS platform:
<header-file src="src/ios/Pushwoosh.framework/Versions/A/Headers/PWNotificationExtensionManager.h" target-dir="ios"/>

4. Update the Notification Service Extension code as follows:

#import "NotificationService.h"
#import "PWNotificationExtensionManager.h"
@interface NotificationService ()
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@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.
When creating a NotificationServiceExtension, Cordova does not link binaries with libraries automatically, so it has to be done manually.
Please make sure that your NotificationServiceExtension target in Xcode has the following Compile Sources and Link Binary With Libraries added:
To add libz.tbd and libc++.tbd, click on the "+" button and type down its names in the drop-down list.
To add libPushwoosh.a library, click on Add Other... -> Add Files..., and find the .a file in the ios_project_root/project_name/Plugins/pushwoosh-cordova-plugin/libPushwoosh.a:

6. Add the "App Groups Capability" for each target of your application

App Groups Capability

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


Share your feedback with us

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.
Copy link
On this page
Share your feedback with us