QuickBlox / quickblox-ios-sdk

QuickBlox iOS SDK for messaging and video calling
https://quickblox.com/developers/IOS
MIT License
397 stars 358 forks source link

Swift Chat does not load dialog for first time #903

Closed manishverma30 closed 6 years ago

manishverma30 commented 6 years ago

New Issue Checklist

Environment details

Info Value
iOS Version e.g. 8.0
Quickblox iOS SDK version e.g. 2.7.6
QuickbloxWebRTC SDK version e.g. 2.2.1
Xcode Version e.g. Xcode 8.1
Repro with our demo sample e.g. does it happen with our demo sample?

Did this work before? Yes I saw this woking before. Now in my project and sample-chat-swift this is not working. I can reproduce the issue.

Expected behavior In ChatViewController.swift this condition should get executed when we are entering with valid dialog from other Viewcontroller. print("Dialog= (dialog)") // Retrieving messages if (self.storedMessages()?.count ?? 0 > 0 && self.chatDataSource.messagesCount() == 0) { self.chatDataSource.add(self.storedMessages()!) }

Actual behavior self.storedMessages()?.count returns with zero value.

Logs Attached.

Title for logs

I have printed dialog also just before problem code area. // Your logs here

Attached Sample-Chat-Swift-Logs

I have enabled both debug and XMPP for logging.

Steps to reproduce the behavior

  1. Get Sample-Chat-Swift project from QuickBlox.
  2. Open in Xcode and I have selected Test account swift2dev10 user.
  3. you get empty screen for Select a Dialog to Chat for the first time. if you come back empty chat screen and again select any Dialog then this time it loads.
  4. This is reproducible in both sample-chat-swift project and mine own project too. Thanks. Manish

Sample-Chat-Swift-Logs.docx img_2493

manishverma30 commented 6 years ago

Swift Chat issue. reproduced in sample chat swift project.

ghost commented 6 years ago

@manishverma30, Please use the Sample-Chat-Swift project from the latest release. This issue was fixed.

ghost commented 6 years ago

Hi @manishverma30, any updates ?

manishverma30 commented 6 years ago

Hi Anndrey, I have these lines on my project Pod file pod 'QMServicesDevelopment', :git => 'https://github.com/QuickBlox/q-municate-services-ios.git', :branch => 'development' pod 'QMCVDevelopment' , :git => 'https://github.com/QuickBlox/QMChatViewController-ios', :branch => 'development' pod 'SearchEmojiOnString'

and now I should replace these with ?? please suggest Thanks. Manish

ghost commented 6 years ago

Hi @manishverma30, Could you provide your ChatViewController.swift?

manishverma30 commented 6 years ago

ChatViewController.swift.zip Hi Andrey, Please find my ChatViewController.swift attached here. Thanks. Manish

ghost commented 6 years ago

Hi @manishverma30, Please check latest release

For fix your issue, please remove 2 lines from:

override func viewWillAppear(_ animated: Bool) {
....
 -    ServicesManager.instance().chatService.addDelegate(self) // remove this line      
 -    ServicesManager.instance().chatService.chatAttachmentService.delegate = self // remove this line      
....
}

and from:

 override func viewDidDisappear(_ animated: Bool) {
....
 -        ServicesManager.instance().chatService.removeDelegate(self)   // remove this line         
 -        ServicesManager.instance().chatService.chatAttachmentService.delegate = nil // remove this line       
....
}

and add 2 lines into:

override func viewDidLoad() {
...
+            ServicesManager.instance().chatService.addDelegate(self) //add this line
+            ServicesManager.instance().chatService.chatAttachmentService.delegate = self // add this line
...
}

Thanks!

manishverma30 commented 6 years ago

Thanks you so much Andrey. issue got resolved. Thanks. Manish