How to set badge when using UNUserNotification for local notifications on IOS10

1.7k Views Asked by At

I am using UNUserNotification to push repeated local notifications to the user. I am trying to set badge number on the app to indicate the missed notifications. I searched through this forum and found iPhone: Incrementing the application badge through a local notification

This says that it is not possible for recurring local notification. That post is couple of years old and they were using UILocal notification.

is this still true for UNUserNotification? Is there no way to set badge count?

1

There are 1 best solutions below

7
On

Set the badge property of a UNMutableNotificationContent object.

let notificationContent = UNMutableNotificationContent()
notificationContent.badge = 3

From the UNMutableNotificationContent documentation:

badge

The number to display as the app’s icon badge.