2
I’m trying to log in to facebook with Ionic/Angularjs.
Whenever I try to login returns this error:
Object {errorMessage: "User cancelled dialog", errorcode: "4201"}
I’m following this example: Login Facebook with Ionic
How to 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;
};
});
Where is the code ?
– Lucas Fontes Gaspareto
@devgaspa mals ! posted the code.
– FernandoPaiva
What version of Ionic/Angularjs are you using ?
– Lucas Fontes Gaspareto
Ionic 1.1.1 and angular 1.4.7.
– FernandoPaiva
Sure? you checked the Ionic-Bundle script for the version? Sometimes, when you install via npm it happens to come earlier versions. And I believe this mistake is happening for this reason.
– Lucas Fontes Gaspareto
check yes @devgaspa Ionic eh 1.1.1 and angular 1.4.7.
– FernandoPaiva