Getting Facebook user info after success login in Ionic Cordova Facebook 4

Viewed 595

I'm trying to get user informations after a success login using IOnic 2 and cordova-plugin-facebook4. The first part showing the access Token is correctly showing up, while after that neither success nor fail are showing anything. I'm trying to simply show an alert with user name gathered from Facebook.

let params = ["public_profile", "email"];
this.facebook.login(params).then(
  function(response) {
    alert("Login Response :" + JSON.stringify(response.status));
    let authId = response.authResponse.userID;
    if (response.status == "connected") {
      this.facebook.api( authId + "/?fields=id,email,first_name,last_name,gender,age_range",
        ['public_profile', 'email'],
        function onSuccess (response) {
          alert(JSON.stringify(response.email));
        },
        function onError (error) {
          alert("Failed: " + error);
        })
    } else {
      alert("Not connected: " + response.status);
    }
  },
  function(response) {
    alert("Other Response : " + JSON.stringify(response))
  });

}

All I'm getting is an alert saying 'connected', no alert for success neither for fail ..

0 Answers
Related