marinofaggiana 4 년 전
부모
커밋
d8a54794d6
1개의 변경된 파일25개의 추가작업 그리고 0개의 파일을 삭제
  1. 25 0
      iOSClient/AppDelegate.swift

+ 25 - 0
iOSClient/AppDelegate.swift

@@ -360,7 +360,32 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             task.setTaskCompleted(success: true)
         }
     }
+    
+    // MARK: - Fetch
 
+    func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
+        if account == "" {
+            completionHandler(UIBackgroundFetchResult.noData)
+            return
+        }
+        NCCommunicationCommon.shared.writeLog("Start perform Fetch [Auto upload]")
+        NCAutoUpload.shared.initAutoUpload(viewController: nil) { (items) in
+            NCCommunicationCommon.shared.writeLog("Completition perform Fetch with \(items) uploads [Auto upload]")
+            if items == 0 {
+                completionHandler(UIBackgroundFetchResult.noData)
+            } else {
+                completionHandler(UIBackgroundFetchResult.newData)
+            }
+        }
+    }
+    
+    // MARK: - Background Networking Session
+
+    func application(_ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) {
+        NCCommunicationCommon.shared.writeLog("Start handle Events For Background URLSession: \(identifier)")
+        backgroundSessionCompletionHandler = completionHandler
+    }
+    
     // MARK: - Push Notifications
     
     func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {