I've got a phonegap application using the ionic framework / angularjs. I'm using the Facebook connect plugin to link in with facebook, although I think that's unrelated at the moment.
I've got the following code. The 'login with facebook'button doesn't acknowledge getting clicked until i've clicked the normal login button first.
A video showing what happens is here: http://screencast.com/t/EkppHm8uLSh - as you can see, not even the log seems to fire.
The markup is:
<div class="row">
<div class="col">
<button class="button button-block button-energized" ng-click="doLogin()">
Login
</button>
</div>
<div class="col">
<a class="button button-block button-assertive" href="#/register">
Register
</a>
</div>
</div>
<div class="row">
<div class="col">
<button class="button button-positive button-block icon-right ion-social-facebook" ng-click="doFBLogin()">
Login with Facebook
</button>
</div>
</div>
The controller:
$scope.doFBLogin = function () {
$log.info("trying fb");
ionPlatform.ready.then(function (device) {
var appID = "redacted";
try {
facebookConnectPlugin.login(["email, user_birthday"],
function (response) {
$scope.options = {};
$scope.options.AccessToken = response.authResponse.accessToken;
$rootScope.nLog($scope.options);
SaveSubmitService.saveLocal('Account', 'FacebookLogin', $scope.options, false).then(function (data) {
$scope.return = data;
$rootScope.nLog(data.data);
localStorage.setItem("SessionKey", $scope.return.data.SessionKey);
localStorage.setItem("Username", $scope.return.data.Username);
$scope.fbpic = {};
$scope.fbpic.PictureURL = "http://graph.facebook.com/" + response.authResponse.userID + "/picture?width=1000";
$scope.fbpic.Username = localStorage.getItem("Username");
$scope.fbpic.SessionKey = localStorage.getItem("SessionKey");
ionPlatform.ready.then(function (device) {
$scope.register();
});
SaveSubmitService.saveLocal('Account', 'GetFacebookPicture', $scope.fbpic, false).then(function (data) {
$location.path('home');
});
});
},
function (response) {
$cordovaDialogs.alert('Facebook login not available at this time', 'Error', 'Ok').then(function () {
});
});
} catch (e) {
console.log("fb init error" + e);
}
});
}