Facebook login with Ionic / AngularJS?

2

I'm trying to login from facebook with Ionic / AngularJS.

Whenever I try to login, I get this error:

  

Object {errorMessage: "User canceled dialog", errorCode: "4201"}

I'm following this example: Login Facebook with Ionic

How do I solve this problem?

var app = angular.module("starter");

app.controller("MainCtrl", function($scope, $state, $ionicHistory, $ionicLoading){

  // This is the success callback from the login method
  var fbLoginSuccess = function(response) {
    console.log("cliquei");
    if (!response.authResponse){
      fbLoginError("Cannot find the authResponse");
      return;
    }

    var authResponse = response.authResponse;

    getFacebookProfileInfo(authResponse)
      .then(function(profileInfo) {
      console.log("Email profile " + profileInfo.email);      
      $ionicLoading.hide();      
    }, function(fail){
      // Fail get profile info
      console.log('profile info fail', fail);
    });
  };

  // This is the fail callback from the login method
  var fbLoginError = function(error){
    console.log('fbLoginError ', error);
    $ionicLoading.hide();
  };

  // This method is to get the user profile info from the facebook api
  var getFacebookProfileInfo = function (authResponse) {
    var info = $q.defer();

    facebookConnectPlugin.api('/me?fields=email,name&access_token=' + authResponse.accessToken, null,
      function (response) {
        console.log(response);
        info.resolve(response);
      },
      function (response) {
        console.log(response);
        info.reject(response);
      }
    );
    return info.promise;
  };
});
    
asked by anonymous 01.12.2015 / 11:37

1 answer

0

resolved. After much searching I ended up using ngOpenFB

link

link

link

    
01.12.2015 / 19:15