Sfoglia il codice sorgente

Add Background task

marinofaggiana 4 anni fa
parent
commit
73c7dd6810
2 ha cambiato i file con 9 aggiunte e 2 eliminazioni
  1. 4 2
      iOSClient/AppDelegate.m
  2. 5 0
      iOSClient/Brand/iOSClient.plist

+ 4 - 2
iOSClient/AppDelegate.m

@@ -163,8 +163,9 @@
     // Auto upload
     self.networkingAutoUpload = [NCNetworkingAutoUpload new];
     
+    // Background task
     if (@available(iOS 13.0, *)) {
-        NSLog(@"configureProcessingTask");
+        NSLog(@"configure ProcessingTask");
         [self configureProcessingTask];
     }
     
@@ -248,7 +249,7 @@
     [self passcodeWithAutomaticallyPromptForBiometricValidation:false];
     
     if (@available(iOS 13.0, *)) {
-        NSLog(@"scheduleProcessingTask");
+        NSLog(@"schedule ProcessingTask");
         [self scheduleProcessingTask];
     }
 }
@@ -545,6 +546,7 @@
         // new task
         BGProcessingTaskRequest *request = [[BGProcessingTaskRequest alloc] initWithIdentifier:NCBrandGlobal.shared.backgroudTask];
         request.requiresNetworkConnectivity = YES;
+        request.requiresExternalPower = NO;
         request.earliestBeginDate = [NSDate dateWithTimeIntervalSinceNow:5];
         BOOL success = [[BGTaskScheduler sharedScheduler] submitTaskRequest:request error:&error];
         if (!success) {

+ 5 - 0
iOSClient/Brand/iOSClient.plist

@@ -2,6 +2,10 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
+	<key>BGTaskSchedulerPermittedIdentifiers</key>
+	<array>
+		<string>com.nextcloud.backgroudTask</string>
+	</array>
 	<key>CFBundleAllowMixedLocalizations</key>
 	<true/>
 	<key>CFBundleDevelopmentRegion</key>
@@ -70,6 +74,7 @@
 	<array>
 		<string>audio</string>
 		<string>fetch</string>
+		<string>processing</string>
 		<string>remote-notification</string>
 	</array>
 	<key>UIFileSharingEnabled</key>