QuickBlox错误与自定义对象(安卓)(QuickBlox Error with Custom

2019-10-17 19:01发布

我想在我的定制对象类插入一些数据,但我得到的错误:“故宫需要用户”。 这里是我的代码:

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) {

             }
});

非常感谢!

Answer 1:

为了创建/更新/删除对象,你必须签署作为用户。

登入

 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);
                    }
                }
            });


文章来源: QuickBlox Error with Custom Object (Android)