简体   繁体   English

解析-使用Facebook登录时isNew()始终返回false

[英]Parse - isNew() always returns false when logging in with Facebook

When attempting to login and signup through Facebook, the method isNew() somehow always returns false , even if the "_User" table is empty or if the user is logging in for the first time (signing up). 尝试通过Facebook登录和注册时,即使“ _User”表为空或用户首次登录(注册),方法isNew()总是会返回false

According to the docs: 根据文档:

isNew(): Indicates whether this ParseUser was created during this session through a call to ParseUser.signUp() or by logging in with a linked service such as Facebook. isNew():指示此ParseUser是在此会话期间通过调用ParseUser.signUp()还是通过使用链接服务(如Facebook)登录创建的。

Here's the code: 这是代码:

private void loginWithFacebook() {
    ParseFacebookUtils.logInWithReadPermissionsInBackground((Activity) getContext(), null, new LogInCallback() {
        @Override
        public void done(ParseUser user, ParseException e) {
            if (user != null) {
                if (user.isNew()) {
                    onLoginListener.onSignupWithFacebook();
                } else {
                    onLoginListener.onLoginWithFacebook();
                }
            } else if (e != null) {
                handleException(e);
            }
        }
    });
}

Other people have come across similar problems and fixed it, but the solutions they've come up with don't apply to my case: 其他人也遇到过类似的问题,并已解决,但他们提出的解决方案不适用于我的情况:

Facebook login with Parse always returns false in user.isNew() Android 使用Parse进行Facebook登录始终在user.isNew()Android中返回false

Facebook Login not working properly (Parse) Facebook登录无法正常运行(解析)

User.isNew() returns false when it should return true User.isNew()在应返回true时返回false

Apart from that, everything else seems to be working fine. 除此之外,其他一切似乎都正常。 The user data is created and stored on the table just like it normally should. 用户数据将像通常那样创建并存储在表中。 Any suggestions? 有什么建议么?

remove enableAutomaticUser() if you have written in Application or BaseActivity class 如果您已经编写了ApplicationBaseActivity类,请删除enableAutomaticUser()

docs says that this method will Enables automatic creation of anonymous users. docs说,此方法将Enables automatic creation of anonymous users.

remove except this three and try may help you.!! 除去这三个,尝试可能会帮助您。

FacebookSdk.sdkInitialize(getApplicationContext());
Parse.initialize(this,getString(R.string.parse_app_id),getString(R.string.parse_client_key));
ParseFacebookUtils.initialize(this);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM