我已经使用QuickBlox服务器和QBRequest.logInWithUserLogin方法登录,连续登录后我可以从当前会话中获取用户信息 例如:(QBSession.currentSession()。currentUser?.fullName)! as String
当我尝试使用参数发布QBCOCustomObject时;有时候它有效,有时它显示“禁止。需要用户”
它是如何在某个时候起作用的,而不是在其他时间起作用。
代码:
if QBSession.currentSession().currentUser != nil {
QBRequest.createObject(params, successBlock: { (response, object) in
MBProgressHUD.hideAllHUDsForView(self.view, animated: true)
print("create object:", object)
print("create response:", response.data)
// Get ID of recent post and create brandTag with multiple brands
if let data: NSData = response.data{
let postId: String = data.valueForKey("_id")! as! String
print("Data: \(postId)")
let param: QBCOCustomObject = QBCOCustomObject()
for brand in self.saveBrand {
param.className = "BrandTag"
param.fields!["Post_id"] = postId
param.fields!["Brand_id"] = BrandQuery.getInstance().retrieveBrandId(brand)
QBRequest.createObject(param, successBlock: { (response: QBResponse, object: QBCOCustomObject?) in
print("Created BrandTag:", object)
}, errorBlock: { (response: QBResponse) in
print(response.error!.description)
})
}
}else{
print("RESPONSE: \(response.data)")
}
self.navigationController?.popViewControllerAnimated(true)
}, errorBlock: {(response: QBResponse) in
MBProgressHUD.hideAllHUDsForView(self.view, animated: true)
let alert: UIAlertView = UIAlertView(title: "Error Uploading", message: response.error?.description, delegate: nil, cancelButtonTitle: "Cancel")
alert.show()
print("Response Error: ", response.error?.description)
})
} else {
MBProgressHUD.hideAllHUDsForView(self.view, animated: true)
let alert: UIAlertView = UIAlertView(title: "Error Uploading", message: "No current user exist", delegate: nil, cancelButtonTitle: "Cancel")
alert.show()
print("No Current User")
}
提前致谢!
答案 0 :(得分:0)
由于以下情况之一,您收到此错误:
1.您不是登录用户。
2.您创建的会话已过期。