I am using the following code to display a number as badge at my apps icon:
func triggerNotification(iAmountToday: Int) {
UNUserNotificationCenter.currentNotificationCenter().requestAuthorizationWithOptions([.Badge, .Sound, .Alert]) { (granted, error) in
if granted {
let content = UNMutableNotificationContent()
content.badge = iAmountToday
content.categoryIdentifier = "com.psv.localNotification"
let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 1.0, repeats: false)
let request = UNNotificationRequest.init(identifier: "AmountTodayUpdate", content: content, trigger: trigger)
let center = UNUserNotificationCenter.currentNotificationCenter()
center.addNotificationRequest(request, withCompletionHandler: { (error) in
if (error != nil) {
print (error)
}
})
}
}
}
Although no error is thrown, the badge is never shown at the apps icon.
What am I doing wrong?
Cheers