新 ParseObject 的 SetReadAccess 错误 [英] SetReadAccess error for new ParseObject
问题描述
我在我的 Android 应用程序的应用程序类中放置了以下代码:
I have the following code placed in my application class of an Android app of mine:
// Register ParseObject subclasses
ParseObject.registerSubclass(Results.class);
// Set up Parse
Parse.enableLocalDatastore(MyApplication.this);
Parse.initialize(MyApplication.this, PARSE_APP_KEY, PARSE_CLIENT_KEY);
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
ParseACL.setDefaultACL(defaultACL, true);
每当我重新安装我的应用程序并创建新的结果对象时,这似乎都很有效.现在,如果我通过 Play 商店更新我的应用程序,或通过 Android Studio 安装它,每当创建新的 Results 对象或任何其他 ParseObject 或其子类时,我都会收到以下错误:
This seems to work great whenever I have a fresh install of my app and I create new Results objects. Now, if I update my app via the Play store, or install over it via Android Studio, I get the following error whenever new Results objects, or any other ParseObject or subclass thereof, are created:
java.lang.IllegalArgumentException: cannot setReadAccess for a user with null id
这是 Parse 的错误吗?我在离线 Todo 示例中得到了相同的结果.
Is this a bug with Parse? I get the same results with the Offline Todo example.
推荐答案
您需要确保保存当前用户.
You need to make sure to save the current user.
// Register ParseObject subclasses
ParseObject.registerSubclass(Results.class);
// Set up Parse
Parse.enableLocalDatastore(MyApplication.this);
Parse.initialize(MyApplication.this, PARSE_APP_KEY, PARSE_CLIENT_KEY);
ParseUser.enableAutomaticUser();
ParseUser.getCurrentUser().saveInBackground(); // <--- This Line
ParseACL defaultACL = new ParseACL();
ParseACL.setDefaultACL(defaultACL, true);
不完全确定我的语法,我只在 Swift 中完成过.
Not entirely sure about my syntax, I've only done it in Swift.
这篇关于新 ParseObject 的 SetReadAccess 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!