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

+ 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.89.0;
+				kind = revision;
+				revision = d325e1f05882616e20caee090d7377735fe44b38;
 			};
 		};
 		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": "20718e68531d8c96fad838a1794a14996064e34d",
-          "version": "0.89.0"
+          "revision": "d325e1f05882616e20caee090d7377735fe44b38",
+          "version": null
         }
       },
       {

+ 23 - 10
iOSClient/AppDelegate.m

@@ -166,7 +166,7 @@
     // Background task
     if (@available(iOS 13.0, *)) {
         [[BGTaskScheduler sharedScheduler] registerForTaskWithIdentifier:NCBrandGlobal.shared.backgroudTask usingQueue:nil launchHandler:^(BGTask *task) {
-            [self handleProcessingTask:task];
+            [self handleBackgroundTask:task];
         }];
     }
     
@@ -250,7 +250,7 @@
     [self passcodeWithAutomaticallyPromptForBiometricValidation:false];
     
     if (@available(iOS 13.0, *)) {
-        [self scheduleProcessingTask];
+        [self scheduleBackgroundTask];
     }
 }
 
@@ -515,12 +515,7 @@
 
 #pragma mark Background Task
 
--(void)handleProcessingTask:(BGTask *)task API_AVAILABLE(ios(13.0))
-{
-    //do things with task
-}
-
--(void)scheduleProcessingTask
+-(void)scheduleBackgroundTask
 {
     if (@available(iOS 13.0, *)) {
         NSError *error = NULL;
@@ -549,6 +544,24 @@
     }
 }
 
+-(void)handleBackgroundTask:(BGTask *)task API_AVAILABLE(ios(13.0))
+{
+    if (self.account == nil || self.account.length == 0) {
+        return;
+    }
+    
+    //do things with task
+    [[NCCommunicationCommon shared] writeLog:@"Start handler background task"];
+    
+    // Verify new photo
+    [[NCAutoUpload shared] initAutoUploadWithViewController:nil];
+    
+    // after 20 sec
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
+        [[NCCommunicationCommon shared] writeLog:@"End 20 sec. handler background task"];
+    });
+}
+
 #pragma mark Fetch
 
 - (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
@@ -558,14 +571,14 @@
         return;
     }
     
-    [[NCCommunicationCommon shared] writeLog:@"Start perform Fetch With Completion Handler"];
+    [[NCCommunicationCommon shared] writeLog:@"Start perform Fetch"];
     
     // Verify new photo
     [[NCAutoUpload shared] initAutoUploadWithViewController:nil];
     
     // after 20 sec
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
-        [[NCCommunicationCommon shared] writeLog:@"End 20 sec. perform Fetch With Completion Handler"];
+        [[NCCommunicationCommon shared] writeLog:@"End 20 sec. perform Fetch"];
         completionHandler(UIBackgroundFetchResultNoData);
     });
 }