1
1
mirror of https://github.com/bitgapp/eqMac.git synced 2024-12-03 07:31:45 +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,11 +9,28 @@
import Cocoa
import SwiftyJSON
import ServiceManagement
import Sparkle
import EmitterKit
@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) {
Application.start()
updater.delegate = self
updateFound.once { _ in
self.updateCanceled.once { _ in
Application.start()
}
}
updateNotFound.once { _ in
Application.start()
}
updater.checkForUpdatesInBackground()
}
func applicationWillTerminate(_ aNotification: Notification) {
@ -32,6 +49,30 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidBecomeActive(_ notification: Notification) {
}
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 AMCoreAudio
import EventKit
//import EventKit
import AVFoundation
//import AudioKit
import Foundation
class Engine {

View File

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