Check if authorized for notifications in AppDelegate before registering

This commit is contained in:
Angelo Stavrow 2020-07-27 13:54:34 -04:00
parent fd56a19edf
commit 2d2c14f9ba
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
1 changed files with 7 additions and 2 deletions

View File

@ -231,8 +231,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
refreshTimer = AccountRefreshTimer() refreshTimer = AccountRefreshTimer()
syncTimer = ArticleStatusSyncTimer() syncTimer = ArticleStatusSyncTimer()
UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .sound, .alert]) { (granted, error) in } UNUserNotificationCenter.current().getNotificationSettings { (settings) in
if settings.authorizationStatus == .authorized {
DispatchQueue.main.async {
NSApplication.shared.registerForRemoteNotifications() NSApplication.shared.registerForRemoteNotifications()
}
}
}
UNUserNotificationCenter.current().delegate = self UNUserNotificationCenter.current().delegate = self
userNotificationManager = UserNotificationManager() userNotificationManager = UserNotificationManager()