[英]chat login not working?(quickblox)
I have been using the same code to login the user to chat 我一直在使用相同的代码登录用户聊天
var user = QBUUser()
user.ID = session.userID
user.login = "123456"
user.password = "password"
QBChat.instance().loginWithUser(user)
But for the last 5 days i get an error that states that the user has to login to chat. 但是最近5天,我收到一条错误消息,指出用户必须登录才能聊天。
2015-08-11 12:13:48.690 buyzar[3063:73416] -[QBChat(Deprecated) sendMessage:] -> return.
2015-08-11 12:13:48.690 buyzar [3063:73416]-[QBChat(已弃用)sendMessage:]->返回。 You have to be logged in in order to use Chat API
您必须先登录才能使用Chat API
Is there any change i am not aware of? 我不知道有什么变化吗?
Make sure that you have a valid session first. 确保首先有一个有效的会话。 Here is the code that I am using and it works perfectly as you use the completion handle to ensure that the user is logged in before you do anything else.
这是我正在使用的代码,当您使用完成句柄来确保用户已登录后再执行其他操作时,它可以完美地工作。
//MARK: - Completions
var logincompletion: ((success: Bool) -> ())?
//MARK: - Login
func loginUser(login: String, password: String, completion:
((success: Bool) -> ())? = nil) {
self.logincompletion = completion
var parameters: QBSessionParameters = QBSessionParameters()
parameters.userEmail = login
parameters.userPassword = password
QBRequest.createSessionWithExtendedParameters(parameters, successBlock: { (response: QBResponse!, session: QBASession!) -> Void in
var currentUser = QBUUser()
currentUser.ID = session.userID
currentUser.password = password
currentUser.login = login
QBChat.instance().addDelegate(self)
QBChat.instance().loginWithUser(currentUser)
}) { (response: QBResponse!) -> Void in
if self.logincompletion != nil {
self.logincompletion!(success: false)
}
}
}
Here is an example of me calling this code: 这是我调用此代码的示例:
ChatManager.SharedInstance.loginUser(UserManager.SharedInstance.user!.email, password: UserManager.SharedInstance.user!.account_id) { (success) -> () in
println("Logged into QuickBlox: \(success)")
if let appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate {
if appDelegate.deviceTokenData != nil {
var deviceIdentifier = UIDevice.currentDevice().identifierForVendor.UUIDString
QBRequest.registerSubscriptionForDeviceToken(appDelegate.deviceTokenData, uniqueDeviceIdentifier: deviceIdentifier, successBlock: { (response: QBResponse!, session: [AnyObject]!) -> Void in
println("registered for push")
}) { (error: QBError!) -> Void in
println("could not reigster for push: \(error)")
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.