|
@@ -65,9 +65,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
|
|
|
|
|
let userAgent = CCUtility.getUserAgent() as String
|
|
|
- let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
|
|
|
let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
|
|
|
|
|
|
+ // Register initialize
|
|
|
+ NotificationCenter.default.addObserver(self, selector: #selector(initialize), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
|
|
|
+
|
|
|
UserDefaults.standard.register(defaults: ["UserAgent": userAgent])
|
|
|
if !CCUtility.getDisableCrashservice() && !NCBrandOptions.shared.disable_crash_service {
|
|
|
FirebaseApp.configure()
|
|
@@ -136,14 +138,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
// Create user color
|
|
|
NCBrandColor.shared.createUserColors()
|
|
|
|
|
|
- // Register initialize
|
|
|
- NotificationCenter.default.addObserver(self, selector: #selector(initialize), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
|
|
|
-
|
|
|
- // Start process Upload, Initialize
|
|
|
+ // Start process Upload
|
|
|
if UIApplication.shared.applicationState != .background {
|
|
|
NKCommon.shared.writeLog("[INFO] Starting process upload and Inizialize main")
|
|
|
networkingProcessUpload = NCNetworkingProcessUpload()
|
|
|
- NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize, userInfo:["atStart":1])
|
|
|
}
|
|
|
|
|
|
// Push Notification & display notification
|
|
@@ -223,8 +221,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
// Account changed ??
|
|
|
if activeAccount.account != account {
|
|
|
settingAccount(activeAccount.account, urlBase: activeAccount.urlBase, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account))
|
|
|
-
|
|
|
- NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
|
|
|
}
|
|
|
|
|
|
// START UPLOAD PROCESS
|
|
@@ -577,6 +573,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
|
|
|
@objc func settingAccount(_ account: String, urlBase: String, user: String, userId: String, password: String) {
|
|
|
|
|
|
+ let accountBackup = self.account
|
|
|
+ let userIdBackup = self.userId
|
|
|
+
|
|
|
self.account = account
|
|
|
self.urlBase = urlBase
|
|
|
self.user = user
|
|
@@ -591,6 +590,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
NKCommon.shared.setup(nextcloudVersion: serverVersionMajor)
|
|
|
}
|
|
|
NCKTVHTTPCache.shared.restartProxy(user: user, password: password)
|
|
|
+
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ if UIApplication.shared.applicationState != .background && (accountBackup != account || userIdBackup != userId) {
|
|
|
+ NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize, second: 0.2)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@objc func deleteAccount(_ account: String, wipe: Bool) {
|
|
@@ -631,8 +636,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
NCNetworking.shared.cancelAllTask()
|
|
|
|
|
|
settingAccount(tableAccount.account, urlBase: tableAccount.urlBase, user: tableAccount.user, userId: tableAccount.userId, password: CCUtility.getPassword(tableAccount.account))
|
|
|
-
|
|
|
- NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
|
|
|
}
|
|
|
}
|
|
|
|