1
1
mirror of https://github.com/bitgapp/eqMac.git synced 2024-12-04 16:31:13 +03:00

started working on ability for user to update the app before it starts

This commit is contained in:
nodeful 2020-05-03 19:48:46 +01:00
parent 3f61b0d8ea
commit c59eaa8fe4
3 changed files with 46 additions and 6 deletions

View File

@ -9,12 +9,29 @@
import Cocoa import Cocoa
import SwiftyJSON import SwiftyJSON
import ServiceManagement import ServiceManagement
import Sparkle
import EmitterKit
@NSApplicationMain @NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate { class AppDelegate: NSObject, NSApplicationDelegate, SUUpdaterDelegate {
var updater = SUUpdater(for: Bundle.main)!
var updateFound = Event<Void>()
var updateNotFound = Event<Void>()
var updateCanceled = Event<Void>()
func applicationDidFinishLaunching(_ aNotification: Notification) { func applicationDidFinishLaunching(_ aNotification: Notification) {
updater.delegate = self
updateFound.once { _ in
self.updateCanceled.once { _ in
Application.start() Application.start()
} }
}
updateNotFound.once { _ in
Application.start()
}
updater.checkForUpdatesInBackground()
}
func applicationWillTerminate(_ aNotification: Notification) { func applicationWillTerminate(_ aNotification: Notification) {
Application.quit() Application.quit()
@ -33,6 +50,30 @@ class AppDelegate: NSObject, NSApplicationDelegate {
} }
func updaterDidNotFindUpdate(_ updater: SUUpdater) {
updateNotFound.emit()
}
func updater(_ updater: SUUpdater, didFindValidUpdate item: SUAppcastItem) {
updateFound.emit()
}
func updater(_ updater: SUUpdater, userDidSkipThisVersion item: SUAppcastItem) {
updateCanceled.emit()
}
func updater(_ updater: SUUpdater, didCancelInstallUpdateOnQuit item: SUAppcastItem) {
updateCanceled.emit()
}
func updater(_ updater: SUUpdater, didDismissUpdateAlertPermanently permanently: Bool, for item: SUAppcastItem) {
// updateCanceled.emit()
}
func userDidCancelDownload(_ updater: SUUpdater) {
updateCanceled.emit()
}
} }

View File

@ -8,9 +8,8 @@
import Cocoa import Cocoa
import AMCoreAudio import AMCoreAudio
import EventKit //import EventKit
import AVFoundation import AVFoundation
//import AudioKit
import Foundation import Foundation
class Engine { class Engine {

View File

@ -1042,7 +1042,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application"; CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.1.1; CURRENT_PROJECT_VERSION = 0.1.0;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = JZA6C97KJA; DEVELOPMENT_TEAM = JZA6C97KJA;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
@ -1102,7 +1102,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application"; CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.1.1; CURRENT_PROJECT_VERSION = 0.1.0;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = JZA6C97KJA; DEVELOPMENT_TEAM = JZA6C97KJA;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;