Marino Faggiana 6 жил өмнө
parent
commit
86e6f19b2a

+ 9 - 2
iOSClient/AppDelegate.m

@@ -403,7 +403,7 @@
 - (void)subscribingNextcloudServerPushNotification
 {
     // test
-    if (self.activeAccount.length == 0)
+    if (self.activeAccount.length == 0 || self.maintenanceMode)
         return;
     
     OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:self.activeUser withUserID:self.activeUserID withPassword:self.activePassword withUrl:self.activeUrl];
@@ -430,8 +430,15 @@
 
 - (void)unsubscribingNextcloudServerPushNotification:(BOOL)withSubscribing
 {
-    if (self.pnDeviceIdentifier == nil || self.pnDeviceIdentifierSignature == nil || self.pnPublicKey == nil)
+    // test
+    if (self.activeAccount.length == 0 || self.maintenanceMode)
+        return;
+    
+    if (self.pnDeviceIdentifier == nil || self.pnDeviceIdentifierSignature == nil || self.pnPublicKey == nil) {
+        if (withSubscribing)
+            [self subscribingNextcloudServerPushNotification];
         return;
+    }
     
     OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:self.activeUser withUserID:self.activeUserID withPassword:self.activePassword withUrl:self.activeUrl];
 

+ 11 - 2
iOSClient/Main/CCMain.m

@@ -338,6 +338,9 @@
 //
 - (void)initializeMain:(NSNotification *)notification
 {
+    NSDictionary *dict = notification.userInfo;
+    BOOL pushNotification = [[dict valueForKey:@"PushNotification"] boolValue];
+    
     _directoryGroupBy = nil;
     _directoryOrder = nil;
     _dateReadDataSource = nil;
@@ -405,6 +408,10 @@
         // Read this folder
         [self readFileReloadFolder];
         
+        // unsubscribing -> subscribing
+        if (pushNotification)
+            [appDelegate unsubscribingNextcloudServerPushNotification:YES];
+        
     } else {
         
         // reload datasource
@@ -1021,7 +1028,8 @@
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
         
         // go to home sweet home
-        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
+        NSDictionary* userInfo = @{@"PushNotification": [NSNumber numberWithBool:YES]};
+        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:userInfo];
         
         [_ImageTitleHomeCryptoCloud setUserInteractionEnabled:YES];
     });
@@ -2639,7 +2647,8 @@
             [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:tableAccount.password];
     
             // go to home sweet home
-            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];        
+            NSDictionary* userInfo = @{@"PushNotification": [NSNumber numberWithBool:YES]};
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:userInfo];        
         }
     });
 }

+ 1 - 1
iOSClient/Main/CCMore.swift

@@ -448,7 +448,7 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
     
     func loginSuccess(_ loginType: NSInteger) {
         
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil)
+        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
         
         appDelegate.selectedTabBarController(Int(k_tabBarApplicationIndexFile))
     }

+ 4 - 2
iOSClient/Main/CCSplit.m

@@ -119,7 +119,8 @@
     self.build = [CCUtility setBuild];
     
     // init home
-    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
+    NSDictionary* userInfo = @{@"PushNotification": [NSNumber numberWithBool:NO]};
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:userInfo];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -181,7 +182,8 @@
 
 - (void)loginSuccess:(NSInteger)loginType
 {
-    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
+    NSDictionary* userInfo = @{@"PushNotification": [NSNumber numberWithBool:YES]};
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:userInfo];
 }
 
 - (void)loginClose

+ 2 - 1
iOSClient/Settings/CCAdvanced.m

@@ -401,7 +401,8 @@
             // Close HUD
             [self.hud hideHud];
             // Inizialized home
-            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
+            NSDictionary* userInfo = @{@"PushNotification": [NSNumber numberWithBool:NO]};
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:userInfo];
         });
     });
 }

+ 4 - 2
iOSClient/Settings/CCManageAccount.m

@@ -201,7 +201,8 @@
 
 - (void)loginSuccess:(NSInteger)loginType
 {
-    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
+    NSDictionary* userInfo = @{@"PushNotification": [NSNumber numberWithBool:YES]};
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:userInfo];
 }
 
 - (void)loginClose
@@ -345,7 +346,8 @@
             [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:tableAccount.password];
  
             // Init home
-            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
+            NSDictionary* userInfo = @{@"PushNotification": [NSNumber numberWithBool:YES]};
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:userInfo];
             
             [self UpdateForm];
         }