From 0afc87cad417ebb5cbfe4634933dc8ddb8c7a445 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Mon, 4 Nov 2019 15:07:51 -0800 Subject: [PATCH] [AltServer] Fixes notifications not appearing on Catalina --- AltServer/AppDelegate.swift | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/AltServer/AppDelegate.swift b/AltServer/AppDelegate.swift index c06f7c13..84b04d9c 100644 --- a/AltServer/AppDelegate.swift +++ b/AltServer/AppDelegate.swift @@ -47,16 +47,20 @@ class AppDelegate: NSObject, NSApplicationDelegate { self.connectedDevicesMenu.delegate = self - if !UserDefaults.standard.didPresentInitialNotification - { - let content = UNMutableNotificationContent() - content.title = NSLocalizedString("AltServer Running", comment: "") - content.body = NSLocalizedString("AltServer runs in the background as a menu bar app listening for AltStore.", comment: "") + UNUserNotificationCenter.current().requestAuthorization(options: [.alert]) { (success, error) in + guard success else { return } - let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil) - UNUserNotificationCenter.current().add(request) - - UserDefaults.standard.didPresentInitialNotification = true + if !UserDefaults.standard.didPresentInitialNotification + { + let content = UNMutableNotificationContent() + content.title = NSLocalizedString("AltServer Running", comment: "") + content.body = NSLocalizedString("AltServer runs in the background as a menu bar app listening for AltStore.", comment: "") + + let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil) + UNUserNotificationCenter.current().add(request) + + UserDefaults.standard.didPresentInitialNotification = true + } } }