自定义对象的QuickBlox错误(Android)

时间:2013-03-07 21:59:19

标签: android quickblox

我想在我的自定义对象类中插入一些数据,但是我收到错误:“禁止。需要用户。”。这是我的代码:

HashMap<String, Object> fields = new HashMap<String, Object>();
fields.put("user", username);
fields.put("name", ada.getTitle());
fields.put("type", ada.getType());
fields.put("text", ada.getText());
fields.put("status", ada.getStatus());
QBCustomObject qbCustomObject = new QBCustomObject();
qbCustomObject.setClassName("Ada");
qbCustomObject.setFields(fields);
qbCustomObject.setUserId(userId);
QBCustomObjects.createObject(qbCustomObject, new QBCallback() {
            @Override
            public void onComplete(Result result) {
            // get creates score
            QBCustomObjectResult qbCustomObjectResult = (QBCustomObjectResult) result;
                    QBCustomObject qbCustomObject = qbCustomObjectResult.getCustomObject();
             }

             @Override
             public void onComplete(Result result, Object o) {

             }
});

非常感谢!

1 个答案:

答案 0 :(得分:2)

要创建/更新/删除对象,您必须以用户身份登录。

登录

 final QBUser user = new QBUser("testuser", "testpassword");

 QBUsers.signIn(user, new QBCallbackImpl() {
                @Override
                public void onComplete(Result result) {
                    if (result.isSuccess()) {
                        QBUserResult qbUserResult = (QBUserResult) result;
                    } else {
                        handleErrors(result);
                    }
                }
            });