2016-12-07 50 views
0

我正在使用Parse SDK 1.13.1 for Android,我需要通过按钮单击注销用户。它的工作,但是当我打电话给ParseUser.getCurrentUser()它给我最后登录的用户而不是null。在Android中解析迁移后未注销ParseUser currentUser的注销功能

对于解析初始化我写下面的代码:

Parse.initialize(new Parse.Configuration.Builder(this).applicationId("PARSE_APPLICATIONID").clientKey("PARSE_CLIENT_KEY").server("PARSE_SERVER_URL").build()); 

对于注销我写下面的代码

ParseUser.logOut(); 

,也试过

ParseUser.getCurrentUser().logOut(); 

ParseUser currentUser = ParseUser.getCurrentUser(); // this should be null but not 

但是,似乎ParseUser.getCurrentUser ();注销后不为空。

如何从缓存中删除当前用户?

请帮我解决这个问题。谢谢

回答

0

无论何时使用任何注册或登录方法,用户都缓存在磁盘上。你可以把这个缓存的会话,并自动承担用户登录。

ParseUser currentUser = ParseUser.getCurrentUser(); 
if (currentUser != null) { 
    // do stuff with the user 
} else { 
    // show the signup or login screen 
} 

您可以通过登录出来清空当前用户。

ParseUser.logOut(); 
ParseUser currentUser = ParseUser.getCurrentUser(); // this will now be null 

确保你把所有的功能正确设置和你不认证用户再等

如果启用自动创建用户,注销,然后获取当前用户会产生新的匿名用户。这在默认情况下在初学者项目中,以便您可以立即开始使用用户和ACL。下面ParseUser像

public static Task<Void> logOutInBackground() 

public static void logOutInBackground(LogOutCallback callback) 

方法:

如果[PFUser enableAutomaticUser];集你appDelegate,当前用户将永远不会返回nill

+0

在回购中发现一个问题,提示它可能是一个错误。 https://github.com/ParsePlatform/Parse-SDK-Android/issues/539 – Cliffordwh

0

请检查以下 ParseUser.logOutInBackground();

ParseUser.logOutInBackground(new LogOutCallback) 

希望它能正常工作...

+0

感谢您的建议。我试过ParseUser.logOutInBackground(新的LogOutCallback),它给出了ParseUser.getCurrentUser()为null。 但是在第二次获取像ParseUser.getCurrentUser()这样的用户详细信息之后,它会给出之前记录的用户。 – Dinesh