I use below code for receiver in ViewControllerChat
:
func chatDidReceive(_ message: QBChatMessage) {
print("REC")
}
If I go to go ViewControllerChat
from ViewControllerHome
and I receive chat, print once REC for me
If I go to go from ViewControllerChat
to ViewControllerHome
by below code and back to ViewControllerChat
and i receive chat, print twice REC for me:
let goController: UIViewController mainStoryboard.instantiateViewController(withIdentifier: "ViewControllerHome")
self.present(goController, animated: true, completion: nil)
This is my plan:
1- From home I go to chat
2- In chat I receive once REC
3- I go to home by present
4- I back to chat from home and receive twice REC
If I open several times chat, I get several times REC
But I want after present ViewControllerChat
, my chatDidReceive
killing!
When trying to dismiss ViewControllerChat
try to remove delegates:
QBRTCClient.instance().removeDelegates
Since the cause of receiving multiple times the same message should be the way you assign delegates in every ViewControllerChat
load. Maybe creating a specified service for implementing this would be better.