Browse Source

#2291

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 years ago
parent
commit
cb014f8f2c
1 changed files with 9 additions and 6 deletions
  1. 9 6
      iOSClient/AppDelegate.swift

+ 9 - 6
iOSClient/AppDelegate.swift

@@ -295,12 +295,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
         NCNetworking.shared.cancelAllDownloadTransfer()
 
-        let content = UNMutableNotificationContent()
-        content.title = NCBrandOptions.shared.brand
-        content.body = NSLocalizedString("_keep_running_", comment: "")
-        let req = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil)
-        let notificationCenter = UNUserNotificationCenter.current()
-        notificationCenter.add(req)
+        if UIApplication.shared.backgroundRefreshStatus == .available {
+
+            let content = UNMutableNotificationContent()
+            content.title = NCBrandOptions.shared.brand
+            content.body = NSLocalizedString("_keep_running_", comment: "")
+            let req = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil)
+            let notificationCenter = UNUserNotificationCenter.current()
+            notificationCenter.add(req)
+        }
 
         NKCommon.shared.writeLog("bye bye")
     }