Marino Faggiana 8 سال پیش
والد
کامیت
88533a3a5f
2فایلهای تغییر یافته به همراه21 افزوده شده و 2 حذف شده
  1. 19 0
      iOSClient/AppDelegate.m
  2. 2 2
      iOSClient/Notification/CCNotification.swift

+ 19 - 0
iOSClient/AppDelegate.m

@@ -474,6 +474,25 @@
         NSLog(@"Receive Notification on Active state");
     }
 }
+
+- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
+{
+    UIApplicationState state = [application applicationState];
+    
+    if (state == UIApplicationStateBackground || (state == UIApplicationStateInactive)) {
+        
+    } else if (state == UIApplicationStateInactive) {
+        
+        // user tapped notification
+        completionHandler(UIBackgroundFetchResultNewData);
+        
+    } else {
+        
+        // app is active
+        completionHandler(UIBackgroundFetchResultNoData);
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Quick Actions - ShotcutItem =====
 #pragma --------------------------------------------------------------------------------------------

+ 2 - 2
iOSClient/Notification/CCNotification.swift

@@ -48,7 +48,6 @@ class CCNotification: UITableViewController, OCNetworkingDelegate {
         super.didReceiveMemoryWarning()
     }
 
-    
     func viewClose() {
         
         // Stop listening notification reload data
@@ -169,14 +168,15 @@ class CCNotification: UITableViewController, OCNetworkingDelegate {
                 
                 cell.icon.image = UIImage(named: "notification")
                 //downloadImage(url: urlIcon)
+                
             } else {
+                
                 cell.icon.image = image
             }
             
             cell.date.text = DateFormatter.localizedString(from: notification.date, dateStyle: .medium, timeStyle: .medium)
             cell.subject.text = notification.subject
             cell.message.text = notification.message
-            
         }
         
         return cell