0

I am using a ionic native facebook function to get the informations, I can get all infomations that I needed from facebook, but the problem I faced is that when I put the informations in my custom function to trigger login, the function of doServerFblogin not called.

Here is my code:

doFbLogin(){
let permissions = new Array<string>();
let nav = this.navCtrl;
let env = this;
//the permissions your facebook app needs from the user
permissions = ["public_profile"];
let fbStatus = '';

this.fb.login(permissions)
.then(function(response){
  let userId = response.authResponse.userID;
  let fbToken = response.authResponse.accessToken;
  fbStatus = response.status;
  let params = new Array<string>();

  //Getting name and gender properties
  env.fb.api("/me?fields=id,email,name,gender", params)
  .then(function(user) {
    user.picture = "https://graph.facebook.com/" + userId + "/picture?type=large";
    console.log("facebook login user :", user);
    console.log(user.picture);
    console.log(user.id);
    console.log(user.email);
    console.log(user.name);
    console.log(fbToken);       
    this.doServerFblogin(user.picture, user.id, user.email, fbToken, user.name); //here to call server api to login
  })
}, function(error){
  console.log(error);
});
}

Anyone know how to make it works. Thanks a lot.

Nulra
  • 527
  • 5
  • 19

0 Answers0