浏览代码

TEST new handleEventsForBackgroundURLSession

marinofaggiana 4 年之前
父节点
当前提交
824ef4d74a

+ 2 - 2
Nextcloud.xcodeproj/project.pbxproj

@@ -2806,8 +2806,8 @@
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/nextcloud/ios-communication-library/";
 			requirement = {
-				kind = exactVersion;
-				version = 0.91.0;
+				kind = revision;
+				revision = e8aa65394f3e5e00782eda50d50fdd8528f5ec43;
 			};
 		};
 		F7C4D88B2534887E00C142DA /* XCRemoteSwiftPackageReference "Parchment" */ = {

+ 2 - 2
Nextcloud.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

@@ -24,8 +24,8 @@
         "repositoryURL": "https://github.com/nextcloud/ios-communication-library/",
         "state": {
           "branch": null,
-          "revision": "08e20e77d155333d68afa8a8a2fc6b202c82ecf5",
-          "version": "0.91.0"
+          "revision": "e8aa65394f3e5e00782eda50d50fdd8528f5ec43",
+          "version": null
         }
       },
       {

+ 1 - 6
iOSClient/AppDelegate.m

@@ -629,12 +629,7 @@
 {
     [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Start handle Events For Background URLSession: %@", identifier]];
         
-    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
-        self.backgroundSessionCompletionHandler = completionHandler;
-        void (^completionHandler)() = self.backgroundSessionCompletionHandler;
-        self.backgroundSessionCompletionHandler = nil;
-        completionHandler();
-    });
+    self.backgroundSessionCompletionHandler = completionHandler;
 }
 
 #pragma mark OpenURL

+ 12 - 0
iOSClient/Networking/NCNetworking.swift

@@ -144,6 +144,18 @@ import Queuer
         delegate?.downloadComplete?(fileName: fileName, serverUrl: serverUrl, etag: etag, date: date, dateLastModified: dateLastModified, length: length, description: description, task: task, errorCode: errorCode, errorDescription: errorDescription)
     }
     
+    func urlSessionDidFinishEvents(forBackgroundURLSession session: URLSession) {
+        
+        #if !EXTENSION
+        if let appDelegate = UIApplication.shared.delegate as? AppDelegate, let completionHandler = appDelegate.backgroundSessionCompletionHandler {
+            NCCommunicationCommon.shared.writeLog("Called urlSessionDidFinishEvents for Background URLSession")
+            appDelegate.backgroundSessionCompletionHandler = nil
+            completionHandler()
+        }
+
+       #endif
+    }
+    
     //MARK: - Pinning check
     
     @objc func checkTrustedChallenge(challenge: URLAuthenticationChallenge, directoryCertificate: String) -> Bool {