首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PFUser currentUser返回零

PFUser currentUser返回零
EN

Stack Overflow用户
提问于 2015-08-12 11:10:47
回答 2查看 495关注 0票数 0

我正在使用Parse,登录和注册工作得很好:[PFUser currentUser]正在返回当前用户。

但在重新启动应用程序后,[PFUser currentUser]将返回零。

为什么应用程序不持久化会话?

我使用的登录代码(来自parse.com):

代码语言:javascript
复制
[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

EN

回答 2

Stack Overflow用户

发布于 2015-08-12 15:11:46

看起来您在某个地方调用了.logout,在这种情况下,应用程序将返回nil for [PFUser currentUser]

如果不自动注销用户,则当前用户将在会话之间持久化。

票数 0
EN

Stack Overflow用户

发布于 2015-08-13 10:27:54

代码语言:javascript
复制
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
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31963513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档