QuickBlox chatDidReceive未调用

时间:2019-01-03 13:46:55

标签: ios swift quickblox swift4.2

我一直在尝试在应用程序内部创建聊天模块, 我的问题是未调用chatDidReceive委托方法,我检查了分配给当前实例的委托,然后在那找到了我的viewcontroller。

这是我的代码:

QBChat.instance.addDelegate(self)
QBRequest.logIn(withUserLogin: "XXXX", password:  "XXXX", successBlock: { (response, user) in    

      QBChat.instance.connect(withUserID: user.id, password: user.password, completion: { (error) in
        DispatchQueue.main.async {
          self.createDialog()
        }
      })

    }) { (response) in
      print(response.error)
    }

然后尝试创建对话框

func createDialog(){

    let dialog = QBChatDialog(dialogID: nil, type: .private)
    dialog.name = "bla bla"
    dialog.occupantIDs =  [1234]


    QBRequest.createDialog(dialog, successBlock: { (response, dialog) in
      print(response)
      print(dialog)
      guard let id = dialog.id else {return}
      self.dialogID = id
      // self.getDialogHistory()

    }) { (response) in
      print(response)
      print(response.error)
    }
  }

现在我正在用这种方法等待传入的消息

func chatDidReceive(_ message: QBChatMessage) {
    print(message)
  }

func chatRoomDidReceive(_ message: QBChatMessage, fromDialogID dialogID: String) {
    print(message)
  }

但没有任何反应,知道我仍在同一个聊天屏幕中

请帮忙吗?

0 个答案:

没有答案