2020-12-22 20:06:25 +00:00
|
|
|
import Cocoa
|
2020-12-22 22:02:56 +00:00
|
|
|
import Sparkle
|
2020-12-22 20:06:25 +00:00
|
|
|
|
|
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
2020-12-23 20:00:44 +00:00
|
|
|
func applicationWillFinishLaunching(_ notification: Notification) {
|
|
|
|
// Check UserDefaults for values; if the key doesn't exist (e.g., if MacUpdatesView hasn't ever been shown),
|
|
|
|
// bool(forKey:) returns false, so set SUUpdater.shared() appropriately.
|
|
|
|
let automaticallyChecksForUpdates = UserDefaults.standard.bool(forKey: "automaticallyChecksForUpdates")
|
|
|
|
let subscribeToBetaUpdates = UserDefaults.standard.bool(forKey: "subscribeToBetaUpdates")
|
|
|
|
|
|
|
|
// Set Sparkle properties.
|
|
|
|
SUUpdater.shared()?.automaticallyChecksForUpdates = automaticallyChecksForUpdates
|
|
|
|
if subscribeToBetaUpdates {
|
|
|
|
SUUpdater.shared()?.feedURL = URL(string: AppcastFeedUrl.beta.rawValue)
|
|
|
|
} else {
|
|
|
|
SUUpdater.shared()?.feedURL = URL(string: AppcastFeedUrl.release.rawValue)
|
|
|
|
}
|
|
|
|
|
|
|
|
// If enabled, check for updates.
|
|
|
|
if automaticallyChecksForUpdates {
|
2021-02-08 21:33:04 +00:00
|
|
|
SUUpdater.shared()?.checkForUpdatesInBackground()
|
2020-12-23 20:00:44 +00:00
|
|
|
}
|
2020-12-22 20:06:25 +00:00
|
|
|
}
|
|
|
|
}
|