marinofaggiana 4 жил өмнө
parent
commit
b5de6efebb

+ 11 - 1
iOSClient/AppDelegate.swift

@@ -220,9 +220,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             
             
             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
         }
         }
-
+        
         NCCommunicationCommon.shared.writeLog("Application will enter in foreground")
         NCCommunicationCommon.shared.writeLog("Application will enter in foreground")
         
         
+        // START TIMER UPLOAD PROCESS
+        if NCUtility.shared.isSimulator() {
+            networkingProcessUpload?.startTimer()
+        }
+        
         // Request Passcode
         // Request Passcode
         passcodeWithAutomaticallyPromptForBiometricValidation(true)
         passcodeWithAutomaticallyPromptForBiometricValidation(true)
         
         
@@ -258,6 +263,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         
         
         if account == "" { return }
         if account == "" { return }
         
         
+        // STOP TIMER UPLOAD PROCESS
+        if NCUtility.shared.isSimulator() {
+            networkingProcessUpload?.stopTimer()
+        }
+        
         NCCommunicationCommon.shared.writeLog("Application did enter in background")
         NCCommunicationCommon.shared.writeLog("Application did enter in background")
         
         
         passcodeWithAutomaticallyPromptForBiometricValidation(false)
         passcodeWithAutomaticallyPromptForBiometricValidation(false)

+ 5 - 1
iOSClient/Networking/NCNetworkingProcessUpload.swift

@@ -45,6 +45,10 @@ class NCNetworkingProcessUpload: NSObject {
     func startTimer() {
     func startTimer() {
         timerProcess = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(process), userInfo: nil, repeats: true)
         timerProcess = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(process), userInfo: nil, repeats: true)
     }
     }
+    
+    func stopTimer() {
+        timerProcess?.invalidate()
+    }
 
 
     @objc private func process() {
     @objc private func process() {
 
 
@@ -56,7 +60,7 @@ class NCNetworkingProcessUpload: NSObject {
         let metadatasUpload = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status == %d OR status == %d", NCGlobal.shared.metadataStatusInUpload, NCGlobal.shared.metadataStatusUploading))
         let metadatasUpload = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status == %d OR status == %d", NCGlobal.shared.metadataStatusInUpload, NCGlobal.shared.metadataStatusUploading))
         counterUpload = metadatasUpload.count
         counterUpload = metadatasUpload.count
         
         
-        timerProcess?.invalidate()
+        stopTimer()
         
         
         print("[LOG] PROCESS-UPLOAD \(counterUpload)")
         print("[LOG] PROCESS-UPLOAD \(counterUpload)")
     
     

+ 7 - 0
iOSClient/Utility/NCUtility.swift

@@ -201,6 +201,13 @@ class NCUtility: NSObject {
         }
         }
         return path.contains("CoreSimulator") || path.contains("sandboxReceipt")
         return path.contains("CoreSimulator") || path.contains("sandboxReceipt")
     }
     }
+    
+    @objc func isSimulator() -> Bool {
+        guard let path = Bundle.main.appStoreReceiptURL?.path else {
+            return false
+        }
+        return path.contains("CoreSimulator")
+    }
 
 
     @objc func isRichDocument(_ metadata: tableMetadata) -> Bool {
     @objc func isRichDocument(_ metadata: tableMetadata) -> Bool {