Selaa lähdekoodia

PushNotification: change token, unsubscribing + subscribing for all users

marinofaggiana 6 vuotta sitten
vanhempi
commit
54cb5ef727
1 muutettua tiedostoa jossa 9 lisäystä ja 8 poistoa
  1. 9 8
      iOSClient/AppDelegate.m

+ 9 - 8
iOSClient/AppDelegate.m

@@ -400,16 +400,17 @@ PKPushRegistry *pushRegistry;
     if (self.activeAccount.length == 0 || self.maintenanceMode || self.pushKitToken.length == 0)
         return;
     
-    NSString *token = [CCUtility getPushNotificationToken:self.activeAccount];
-    
-    if (![token isEqualToString:self.pushKitToken]) {
-        if (token != nil) {
-            // token has changed, unsubscribing + subscribing for all acconts
-            for (tableAccount *result in  [[NCManageDatabase sharedInstance] getAllAccount]) {
+    for (tableAccount *result in [[NCManageDatabase sharedInstance] getAllAccount]) {
+        
+        NSString *token = [CCUtility getPushNotificationToken:result.account];
+        
+        if (![token isEqualToString:self.pushKitToken]) {
+            if (token != nil) {
+                // unsubscribing + subscribing
                 [self unsubscribingNextcloudServerPushNotification:result.account url:result.url withSubscribing:true];
+            } else {
+                [self subscribingNextcloudServerPushNotification:result.account url:result.url];
             }
-        } else {
-            [self subscribingNextcloudServerPushNotification:self.activeAccount url:self.activeUrl];
         }
     }
 }