Setting up Badges
This guide describes the process of implementing Badges for Pushwoosh iOS SDK
Starting with version 6.4.0 of Pushwoosh iOS SDK, the process of managing and setting badges through push notifications has changed.
If you were previously using the badges number to indicate the number of received push notifications in your application, you have to migrate to newer version of iOS SDK (6.4.0 or later). The older versions will be supported until the end of the second quarter of 2022.
To set up badges, follow the steps below:

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

2. Select the "Notification Service Extension"

Adding Notification Service Extension

3. Copy the code from the code block and add it to your project as shown in the pictures below:

Swift
Objective-C
1
PWNotificationExtensionManager.shared().handle(request, contentHandler: contentHandler)
Copied!
1
[[PWNotificationExtensionManager sharedManager] handleNotificationRequest:request contentHandler:contentHandler];
Copied!
Objective-C
Swift

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

App Groups Capability
Info.plist

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

1
<key>PW_APP_GROUPS_NAME</key>
2
<string>group.com.example.demoapp_example</string>
Copied!

5. If you do not want to use Info.plist file, use the method below and add the code to your NotificationServiceExtension class.

Swift
Objective-C
1
PWNotificationExtensionManager.shared().handle(request, withAppGroups: "group.com.example.demoapp_example")
Copied!
1
[[PWNotificationExtensionManager sharedManager] handleNotificationRequest:request withAppGroups:@"group.com.example.demoapp_example"];
Copied!

Well Done!

Send Push Notification with Badges

If you want to send push notification with badges from Pushwoosh Control Panel, just add a desired badge value to the badges text field as shown in the picture below:
Badges value
You can use the following value formats to send badges correctly: +1, -1 or 5. If you want to increment badge value, use "+" sign, if you want to decrement badges, use "-" sign. You can also set the exact number by using e.g. 5 with no sign.

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.