i tried a lot of times get the username field insteal a number. but even looking for docs on the web about the related plugin i can´ t get. i apreciate if someone could help me to implement this in my code:
$scope.loginFacebook = function(){
//Browser Login
if(!(ionic.Platform.isIOS() || ionic.Platform.isAndroid())){
Parse.FacebookUtils.logIn(null, {
success: function(user) {
console.log(user);
if (!user.existed()) {
alert("User signed up and logged in through Facebook!");
} else {
alert("User logged in through Facebook!");
}
// go to home state:
$rootScope.user = user;
$rootScope.isLoggedIn = true;
$state.go('app.home');
},
error: function(user, error) {
alert("User cancelled the Facebook login or did not fully authorize.");
}
});
}
//Native Login
else {
$cordovaFacebook.login(["public_profile", "email"]).then(function(success){
console.log(success);
//Need to convert expiresIn format from FB to date
var expiration_date = new Date();
expiration_date.setSeconds(expiration_date.getSeconds() + success.authResponse.expiresIn);
expiration_date = expiration_date.toISOString();
var facebookAuthData = {
"id": success.authResponse.userID,
"access_token": success.authResponse.accessToken,
"expiration_date": expiration_date
};
Parse.FacebookUtils.logIn(facebookAuthData, {
success: function(user) {
console.log(user);
if (!user.existed()) {
alert("User signed up and logged in through Facebook!");
} else {
alert("User logged in through Facebook!");
}
// go to home state:
$rootScope.user = user;
$rootScope.isLoggedIn = true;
$state.go('app.home');
},
error: function(user, error) {
alert("User cancelled the Facebook login or did not fully authorize.");
}
});
}, function(error){
console.log(error);
});
}
};