Parcourir la source

修复应用打开聊天界面切到后台再回到前端页面不刷新问题

ganzf il y a 1 an
Parent
commit
259d1f614a
2 fichiers modifiés avec 15 ajouts et 9 suppressions
  1. 11 3
      AIIM/AIIM/AppDelegate.m
  2. 4 6
      AIIM/AIIM/Controller/chat/ChatController.m

+ 11 - 3
AIIM/AIIM/AppDelegate.m

@@ -40,6 +40,8 @@
 @property (nonatomic, strong) JSGController * _Nullable jsyuyinctr;
 
 
+@property (nonatomic) BOOL isNotification;
+
 @end
 
 @implementation AppDelegate
@@ -49,6 +51,7 @@
     // Override point for customization after application launch.
     app = self;
     self.isJitsiMeet=false;
+    _isNotification=false;
     self.shouldShowLock = YES;
     [self initJSMSDK];
     [self setupListener];
@@ -75,12 +78,16 @@
     NSLog(@"applicationDidBecomeActive");
     if(self.isLogin){
         [self sartWebsocket];
-        
         if(self.isJitsiMeet){
             [_floatWindow viewInFload:0];
         }
-        
         [self showLockScreen];
+        if(!_isNotification){
+            if ([[self.window jk_currentViewController] isKindOfClass:ChatController.class]) {
+                ChatController * currentChatVc = (ChatController *)[self.window jk_currentViewController];
+                [currentChatVc reloadAllData];
+            }
+        }
     }
     
     [self startTimer];
@@ -88,6 +95,7 @@
 }
 -(void)applicationDidEnterBackground:(UIApplication *)application{
     NSLog(@"applicationDidEnterBackground");
+    _isNotification=false;
 //    [self endWebsocket];
     __block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
             [application endBackgroundTask:bgTask];
@@ -595,7 +603,7 @@
 - (void)handleNotification:(NSDictionary *)userInfo {
     NSDictionary * tempDict = userInfo[@"imMsg"];
     NSDictionary * imMsg = tempDict[@"message"];
-    
+    _isNotification=true;
     NSMutableDictionary * mutablemsg = imMsg.mutableCopy;
     NSLog(@"------mutablemsg:%@",mutablemsg);
     NSDictionary * user = [UDManager.shareInstance getDDManager:dkuserinfo];

+ 4 - 6
AIIM/AIIM/Controller/chat/ChatController.m

@@ -250,6 +250,7 @@ static const CGFloat kQuoteViewHeight = 46.0f;
 //    NSLog(@"self.chatId:%@",self.chatId);
     [ChatListStore.shareInstance chatDidOpen:chatMsg];
     [GWebSocket.shareInstance chekWebSocket];
+    [self movetoBotton];
 }
 
 
@@ -271,7 +272,7 @@ static const CGFloat kQuoteViewHeight = 46.0f;
 -(void)viewWillDisappear:(BOOL)animated{
     [super viewWillDisappear:animated];
     [self endTimer];
-    NSLog(@"viewWillDisappear-----");
+//    NSLog(@"viewWillDisappear-----");
     
 }
 
@@ -618,15 +619,12 @@ static const CGFloat kQuoteViewHeight = 46.0f;
             _canloadhistory = false;
         }
     }
-//    if (msgList.count%16 == 0) {
-//        _canloadhistory = true;
-//    }else{
-//        _canloadhistory = false;
-//    }
+
     
 }
 
 -(void)movetoBotton{
+//    NSLog(@"movetoBotton------movetoBotton");
     if (self.messageArray.count>0) {
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
             NSIndexPath *lastRowIndexPath = [NSIndexPath indexPathForRow:([self._tableView numberOfRowsInSection:0] - 1) inSection:0];