0

I am trying to log my users with Facebook, but can't figure out how to do it.

This is the code I have so far :

    facebookConnectPlugin.getLoginStatus( 
      function(status) { 

        if (status.status != "connected") {
          facebookConnectPlugin.login(
            ['public_profile', 'email'], 
            function(success) {
              console.log("Success", success);
            }, 
            function(error) {
              console.log("Error", error);
            }
          );
        }
        else {
          console.log("logging status : ", status.status);
        }
      },
      function(error) {
        console.log("Getting logging status failed : ", error);
      }
    );

On my Android device, I do not have the Facebook app installed, and I am not logged into Facebook on any browser.

I would expect the facebookConnectPlugin.login() method to popup the login form, but instead this is what it returns :

enter image description here

Which basically means : "You did not enter. You are not connected to Facebook. Enter Facebook and try again".

I looked into this Meteor plugin to see how they were doing it, but they respect the exact same logic.

I am not sure what to do from here. Any suggestion is most welcome !

Alexandre Bourlier
  • 3,972
  • 4
  • 44
  • 76

1 Answers1

1

you can try code for get Login Status read more here

var fbLoginSuccess = function (userData) {
alert("UserInfo: " + JSON.stringify(userData));
facebookConnectPlugin.getLoginStatus(
    function (status) {
        alert("current status: " + JSON.stringify(status));

    }
);

};

you can try code for get User Profile.

  facebookConnectPlugin.login( ["public_profile","email"],
            function (response) {

                if(response.authResponse.userID!=''){
                    facebookConnectPlugin.api(response.authResponse.userID+"/?fields=id,email,first_name", ["public_profile"],
                    function (response) {
                        console.log('SUCCESS:'+response);
                        alert('first_name : '+response.first_name+',email:'+response.email+',id:'+response.id);
                    },
                    function (response) {
                        console.log('ERROR:'+response);
                    });
                }    

            }, 
            function (response) {   
                    console.log('ERROR:'+response);
           });

let me know if its not working...

Kishore Vaishnav
  • 510
  • 3
  • 17
  • Thanks for helping out. However I am getting the exact same result, which is not surprising given that we are still calling `facebookConnectPlugin.login()` with a logged out user, which leads to the popup copy pasted above. Any idea how to work around this ? – Alexandre Bourlier Apr 27 '16 at 08:32