在_Installation的表中加了owner的Pointer來紀錄用戶登陸了那個裝置。我希望在用戶登出時把_Installation中的owner移除,故此調用了以下代碼:

AVInstallation installation = AVInstallation.getCurrentInstallation();
installation.remove("owner");
installation.saveInBackground(new SaveCallback() {
@Override
public void done(AVException e) {
if (e != null) {
} else {
AVUser.this.logOut();
}
}
});

但調用代表後,_Installation中的owner仍然存在。
想請問如何可以把_Installation中的owner移除或設為空白值?

_Installation表的ACL已把delete / update設定為public

你好,你需要用 AVQuery 查询目标 objectId,并加上 query.include("owner") 的查询条件,然后在回调的 list 里, AVObject owner = list.get(0).getAVObject("owner");来拿到 owner 对象操作后,最后 saveInBackground();

那有方法可owner這個field設定成空白嗎?

纠正下,remove 在 query 下是可以行的,像这样:

AVQuery<AVObject> query = AVQuery.getQuery("_Installation");
        query.whereEqualTo("objectId", "566541ed60b204d55d5840cd");
        query.findInBackground(new FindCallback<AVObject>() {
            @Override
            public void done(final List<AVObject> list, AVException e) {
//                list.get(0).put("owner", "");
                list.get(0).remove("owner");
                list.get(0).saveInBackground(new SaveCallback() {
                    @Override
                    public void done(AVException e) {
                        if (e == null) {

                        } else {
                            e.printStackTrace();
                        }
                    }
                });

            }
        });

我测下,是不是 AVInstallation 的这个方法有问题。

好的,有勞你測一下

你好,我也遇到这个问题,请问现在解决了么