From 2d2c14f9baca6c2a8c7b398d007b0b069dc90448 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Mon, 27 Jul 2020 13:54:34 -0400 Subject: [PATCH] Check if authorized for notifications in AppDelegate before registering --- Mac/AppDelegate.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index 1937c8c3b..322b772f7 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -231,8 +231,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, refreshTimer = AccountRefreshTimer() syncTimer = ArticleStatusSyncTimer() - UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .sound, .alert]) { (granted, error) in } - NSApplication.shared.registerForRemoteNotifications() + UNUserNotificationCenter.current().getNotificationSettings { (settings) in + if settings.authorizationStatus == .authorized { + DispatchQueue.main.async { + NSApplication.shared.registerForRemoteNotifications() + } + } + } UNUserNotificationCenter.current().delegate = self userNotificationManager = UserNotificationManager()