marinofaggiana 4 年之前
父節點
當前提交
5729ef16b0
共有 2 個文件被更改,包括 4 次插入9 次删除
  1. 1 9
      iOSClient/AppDelegate.m
  2. 3 0
      iOSClient/Utility/NotificationCenter+MainThread.swift

+ 1 - 9
iOSClient/AppDelegate.m

@@ -1009,16 +1009,8 @@
     
     // after 20 sec
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
-        
-        NSInteger results = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session != ''"] page:0 limit:0 sorted:@"fileName" ascending:NO].count;
-        
-        if (results > 0) {
-            completionHandler(UIBackgroundFetchResultNewData);
-        } else {
-            completionHandler(UIBackgroundFetchResultNoData);
-        }
-        
         [[NCCommunicationCommon shared] writeLog:@"[LOG] End 20 sec. perform Fetch With Completion Handler"];
+        completionHandler(UIBackgroundFetchResultNoData);
     });
 }
 

+ 3 - 0
iOSClient/Utility/NotificationCenter+MainThread.swift

@@ -26,6 +26,9 @@ import Foundation
 extension NotificationCenter {
 
     func postOnMainThread(name: String, object anObject: Any? = nil, userInfo aUserInfo: [AnyHashable : Any]? = nil) {
+        if UIApplication.shared.applicationState == .background {
+            return
+        }
         DispatchQueue.main.async {
             NotificationCenter.default.post(name: Notification.Name.init(rawValue: name), object: anObject, userInfo: aUserInfo)
         }