我有一个用户注册方法,如下所示:
user.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
// Link user to the 'User' role
ParseQuery<ParseRole> roleQuery = ParseRole.getQuery();
roleQuery.whereEqualTo("name", "User");
roleQuery.getFirstInBackground(new GetCallback<ParseRole>() {
@Override
public void done(ParseRole parseRole, ParseException e) {
if (e == null) {
//final ParseRole tempParseRl = parseRole;
ParseRelation<ParseUser> tempRel = parseRole.getUsers();
Log.i("ParseRole: ", parseRole.getName().toString());
parseRole.getUsers().add(user);
//TODO: 4. Delete reg key used for this user
}
// Error on Role ACL
else {
dMenuVerData.dismiss();
Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
});
//1. Hide the progress bar
dataVerPBar.setVisibility(View.GONE);
//2. Show okBtn & successTxt
okBtn.setVisibility(View.VISIBLE);
userSuccessTxt.setVisibility(View.VISIBLE);
dataVerTitle.setText("Congratulations!");
//ParseRelation<ParseUser> tempRel = new ParseRelation<ParseUser>();
//tempParseRl.put("users");
} else {
// Dismiss dialog, show Parse error
dMenuVerData.dismiss();
Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
});
执行以下行:
<role>.getUsers().add(user);
我希望能够在“用户”下看到最近注册的用户,而不是这个表是空的:
我错过了什么?是
<role>.getUsers().add(user);
工作正常吗?感谢。
答案 0 :(得分:0)
解决方案在将新用户添加到ParseRelation后使用<role>.saveInBackground();
方法,因此在注册成功后我添加了:
...
parseRole.getUsers().add(user);
parseRole.saveInBackground();
...
我希望这会有所帮助。
答案 1 :(得分:0)
更改用户关系后,您没有保存角色
我能看到您将用户添加到了什么(您从parseRole.getUsers()
获得的本地列表,但没有保存(将更改与远程版本同步)