Skip to content Skip to sidebar Skip to footer

Parsefacebookutils Returning Wrong Values In Parse

for my android application i wanted to integrate a facebook login, so i did exactly what is here: https://github.com/ParsePlatform/IntegratingFacebookTutorial Everything seems to

Solution 1:

This is what i had done for facebookparse.com login

LoginFragment.java

privateParseLoginConfig config;

@OverridepublicViewonCreateView(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState, 1);
    rootView = inflater.inflate(R.layout.layout_login, container, false);
    config = ParseLoginConfig.fromBundle(getArguments(), getActivity());
    return rootView;
}

privatevoidloginUsingFacebook() {
    // TODO Auto-generated method stubif (config.isFacebookLoginNeedPublishPermissions()) {

        ParseFacebookUtils.logInWithPublishPermissionsInBackground(
                getActivity(), Arrays.asList("public_profile", "email"),
                facebookLoginCallbackV4);
    } else {
        ParseFacebookUtils.logInWithReadPermissionsInBackground(
                getActivity(), Arrays.asList("public_profile", "email"),
                facebookLoginCallbackV4);
    }
}


privateLogInCallback facebookLoginCallbackV4 = newLogInCallback() {
    @Overridepublicvoiddone(ParseUser user, ParseException e) {
        if (isActivityDestroyed()) {
            return;
        }

        if (user == null) {
            loadingFinish();
            if (e != null) {
                showToast(R.string.com_parse_ui_facebook_login_failed_toast);
                debugLog(getString(R.string.com_parse_ui_login_warning_facebook_login_failed)
                        + e.toString());
            }
        } elseif (user.isNew()) {
            GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(),
                    newGraphRequest.GraphJSONObjectCallback() {
                        @OverridepublicvoidonCompleted(JSONObject fbUser,
                                GraphResponse response) {
                            /*
                             * If we were able to successfully retrieve the
                             * Facebook user's name, let's set it on the
                             * fullName field.
                             */Log.e("facebook User", fbUser.toString());
                            final ParseUser parseUser = ParseUser
                                    .getCurrentUser();
                            if (fbUser != null
                                    && parseUser != null
                                    && fbUser.optString("name").length() > 0) {
                                parseUser.put(USER_OBJECT_NAME_FIELD,
                                        fbUser.optString("name"));
                                parseUser.put(USER_OBJECT_EMAIL_FIELD,
                                        fbUser.optString("email"));
                                parseUser
                                        .saveInBackground(newSaveCallback() {
                                            @Overridepublicvoiddone(
                                                    ParseException e) {
                                                if (e != null) {
                                                    debugLog(getString(R.string.com_parse_ui_login_warning_facebook_login_user_update_failed)
                                                            + e.toString());
                                                }
                                                ParseInstallation installation = ParseInstallation
                                                        .getCurrentInstallation();
                                                installation
                                                        .put(BaseFragment.INSTALLATION_UNIQUE_ID,
                                                                parseUser
                                                                        .getUsername());
                                                installation
                                                        .saveInBackground();
                                                loginSuccess();
                                            }
                                        });
                            }
                        }
                    }).executeAsync();
        } 
    }
};

Note :Remove toast messages and and text me if any query!!

Post a Comment for "Parsefacebookutils Returning Wrong Values In Parse"