QuickBlox Error with Custom Object (Android)

喜欢而已 提交于 2020-01-05 04:20:11

问题


I want to insert some data in my Custom-Object Class, but I get the error: "Forbidden. Need user.". Here's my code:

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

             }
});

Thanks very much!


回答1:


In order to create/update/delete object you have to be signed in as user.

Sign-In

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


来源:https://stackoverflow.com/questions/15282585/quickblox-error-with-custom-object-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!