瀏覽代碼

add pushKitToken

marinofaggiana 6 年之前
父節點
當前提交
6715191c16
共有 2 個文件被更改,包括 8 次插入5 次删除
  1. 3 0
      iOSClient/AppDelegate.h
  2. 5 5
      iOSClient/AppDelegate.m

+ 3 - 0
iOSClient/AppDelegate.h

@@ -83,6 +83,9 @@
 @property (nonatomic, strong) AVPlayer *player;
 @property (nonatomic, strong) AVPlayerViewController *playerController;
 
+// Push Norification Token
+@property (nonatomic, strong) NSString *pushKitToken;
+
 // Remenu
 @property (nonatomic, strong) REMenu *reMainMenu;
 @property (nonatomic, strong) REMenuItem *selezionaItem;

+ 5 - 5
iOSClient/AppDelegate.m

@@ -563,15 +563,15 @@ PKPushRegistry *pushRegistry;
     if (self.activeAccount.length == 0 || self.maintenanceMode)
         return;
     
-    NSString *pushKitToken = [self stringWithDeviceToken:credentials.token];
+    self.pushKitToken = [self stringWithDeviceToken:credentials.token];
 
     NSString *token = [CCUtility getPushNotificationToken:self.activeAccount];
-    if (![token isEqualToString:pushKitToken]) {
+    if (![token isEqualToString:self.pushKitToken]) {
         if (token != nil) {
             // unsubscribing + subscribing
-            [self unsubscribingNextcloudServerPushNotification:self.activeAccount url:self.activeUrl token:pushKitToken];
+            [self unsubscribingNextcloudServerPushNotification:self.activeAccount url:self.activeUrl token:self.pushKitToken];
         } else {
-            [self subscribingNextcloudServerPushNotification:self.activeAccount url:self.activeUrl token:pushKitToken];
+            [self subscribingNextcloudServerPushNotification:self.activeAccount url:self.activeUrl token:self.pushKitToken];
         }
     }
 }
@@ -599,7 +599,7 @@ PKPushRegistry *pushRegistry;
                         content.title = @"Nextcloud Talk";
                     } else {
                         content.title = app.capitalizedString;
-                    }                    
+                    }
                     if (subject) {
                         content.body = subject;
                     } else {