Browse Source

coding

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 years ago
parent
commit
83bc552aeb

+ 2 - 0
iOSClient/AppDelegate.swift

@@ -351,6 +351,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
     /*
     @discussion Schedule a refresh task request to ask that the system launch your app briefly so that you can download data and keep your app's contents up-to-date. The system will fulfill this request intelligently based on system conditions and app usage.
+     < MAX 30 seconds >
      */
     func scheduleAppRefresh() {
 
@@ -366,6 +367,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
     /*
      @discussion Schedule a processing task request to ask that the system launch your app when conditions are favorable for battery life to handle deferrable, longer-running processing, such as syncing, database maintenance, or similar tasks. The system will attempt to fulfill this request to the best of its ability within the next two days as long as the user has used your app within the past week.
+     < MAX over 1 minute >
      */
     func scheduleAppProcessing() {
 

+ 1 - 0
iOSClient/Brand/iOSClient.plist

@@ -98,6 +98,7 @@
 	<key>UIBackgroundModes</key>
 	<array>
 		<string>audio</string>
+		<string>fetch</string>
 		<string>processing</string>
 		<string>remote-notification</string>
 	</array>

+ 18 - 0
iOSClient/Utility/NCAskAuthorization.swift

@@ -111,4 +111,22 @@ class NCAskAuthorization: NSObject {
             break
         }
     }
+
+    #if !EXTENSION
+    func checkBackgroundRefreshStatus() {
+        switch UIApplication.shared.backgroundRefreshStatus {
+        case .available:
+            print("Background fetch is enabled")
+        case .denied:
+            print("Background fetch is explicitly disabled")
+            // Redirect user to Settings page only once; Respect user's choice is important
+            UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
+        case .restricted:
+            // Should not redirect user to Settings since he / she cannot toggle the settings
+            print("Background fetch is restricted, e.g. under parental control")
+        default:
+            print("Unknown property")
+        }
+    }
+    #endif
 }