我正在使用Parse,登录和注册工作得很好:[PFUser currentUser]正在返回当前用户。
但在重新启动应用程序后,[PFUser currentUser]将返回零。
为什么应用程序不持久化会话?
我使用的登录代码(来自parse.com):
[PFUser logInWithUsernameInBackground:self.username.text password:self.password.text
block:^(PFUser *user, NSError *error) {
if (user) {
// Do stuff after successful login.
} else {
// The login failed. Check error to see why.
}
}];编辑2:创建新项目,它可以工作。我不知道怎么做,也不知道为什么,但它有效。
编辑:整个项目中没有logout

发布于 2015-08-12 15:11:46
看起来您在某个地方调用了.logout,在这种情况下,应用程序将返回nil for [PFUser currentUser]。
如果不自动注销用户,则当前用户将在会话之间持久化。
发布于 2015-08-13 10:27:54
PFUser *currentUser = [PFUser currentUser];
if (currentUser) {
//save the installation
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
currentInstallation[@"installationUser"] = [[PFUser currentUser]objectId];
// here we add a column to the installation table and store the current user’s ID
// this way we can target specific users later
// while we’re at it, this is a good place to reset our app’s badge count
// you have to do this locally as well as on the parse server by updating
// the PFInstallation object
}https://stackoverflow.com/questions/31963513
复制相似问题