Add icon badge notification number.

This commit is contained in:
Maurice Parker 2019-04-23 07:48:22 -05:00
parent 91e009932b
commit 717d09b2be
1 changed files with 10 additions and 0 deletions

View File

@ -9,6 +9,7 @@
import UIKit
import RSCore
import Account
import UserNotifications
var appDelegate: AppDelegate!
@ -28,6 +29,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
didSet {
if unreadCount != oldValue {
postUnreadCountDidChangeNotification()
UIApplication.shared.applicationIconBadgeNumber = unreadCount
}
}
}
@ -78,6 +80,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
self.unreadCount = AccountManager.shared.unreadCount
}
UNUserNotificationCenter.current().requestAuthorization(options:[.badge]) { (granted, error) in
if granted {
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}
return true
}