From 7b3f78082ebb441fb170e58e246007b560ef8e7e Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Wed, 25 Sep 2019 01:23:23 -0700 Subject: [PATCH] [AltServer] Presents info notification on first launch --- AltServer/AppDelegate.swift | 12 ++++++++++++ .../UserDefaults+AltServer.swift | 9 +++++++++ 2 files changed, 21 insertions(+) rename AltServer/{Connections => Extensions}/UserDefaults+AltServer.swift (68%) diff --git a/AltServer/AppDelegate.swift b/AltServer/AppDelegate.swift index 38a734a0..c06f7c13 100644 --- a/AltServer/AppDelegate.swift +++ b/AltServer/AppDelegate.swift @@ -46,6 +46,18 @@ class AppDelegate: NSObject, NSApplicationDelegate { self.statusItem = item 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: "") + + let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil) + UNUserNotificationCenter.current().add(request) + + UserDefaults.standard.didPresentInitialNotification = true + } } func applicationWillTerminate(_ aNotification: Notification) diff --git a/AltServer/Connections/UserDefaults+AltServer.swift b/AltServer/Extensions/UserDefaults+AltServer.swift similarity index 68% rename from AltServer/Connections/UserDefaults+AltServer.swift rename to AltServer/Extensions/UserDefaults+AltServer.swift index cb4634b3..499cf69e 100644 --- a/AltServer/Connections/UserDefaults+AltServer.swift +++ b/AltServer/Extensions/UserDefaults+AltServer.swift @@ -19,6 +19,15 @@ extension UserDefaults } } + var didPresentInitialNotification: Bool { + get { + return self.bool(forKey: "didPresentInitialNotification") + } + set { + self.set(newValue, forKey: "didPresentInitialNotification") + } + } + func registerDefaults() { if self.serverID == nil