diff --git a/Air Drop Assistant/AppDelegate.swift b/Air Drop Assistant/AppDelegate.swift index c00f080..ec75a8d 100644 --- a/Air Drop Assistant/AppDelegate.swift +++ b/Air Drop Assistant/AppDelegate.swift @@ -38,9 +38,17 @@ class AppDelegate: NSObject, NSApplicationDelegate, DataModelDelegate, PrefDataM let updater = UpdateCheck() let prefViewController = PreferencesViewController() + func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool { + // Ensure that the app doesn't show the menu bar or Dock icon when reopened + NSApp.setActivationPolicy(.accessory) + return false + } func applicationDidFinishLaunching(_ aNotification: Notification) { NSLog("ADA Launched") - + NSApp.setActivationPolicy(.accessory) + if isAppAlreadyRunning() { + NSApp.terminate(nil) + } let appService = SMAppService.agent(plistName: "com.ttinc.Air-Drop-Assistant.plist") if CommandLine.arguments.count > 1 { if airDropManagedDisabled() { @@ -86,9 +94,6 @@ AirDrop is disabled by an MDM Profile. Please contact your MDM administrator. alert.runModal() NSApp.terminate(nil) } - if isAppAlreadyRunning() { - NSApp.terminate(nil) - } if UserDefaults.standard.bool(forKey: "afterFirstLaunch") == false && appService.status != .enabled { diff --git a/Air Drop Assistant/Base.lproj/Main.storyboard b/Air Drop Assistant/Base.lproj/Main.storyboard index 14df07e..5e8b4e1 100644 --- a/Air Drop Assistant/Base.lproj/Main.storyboard +++ b/Air Drop Assistant/Base.lproj/Main.storyboard @@ -8,6 +8,9 @@ + + + @@ -674,9 +677,6 @@ - - -