Vote count:
0
I'm developing and HTML5/CSS/Javascript PhoneGap app that should work as native app for android and iOS and is compiled using the PhoneGap Build service. The app uses Facebook login.
The login is done through the JAVASCRIPT Api. So I have this simple HTML page:
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="http://ift.tt/J5OMPW" type="text/javascript"></script>
<script src="cordova.js" type="text/javascript"></script>
</head>
<body>
<div id="fb-root"></div>
<script type="text/javascript">
$(document).on('click', '#login', function(){
$('.navigation').hide();
$('#center-container').hide();
$('img[src*="loading.gif"]').show();
facebookConnectPlugin.login(["email,user_birthday,publish_actions"], function(response) {
if(response.authResponse) {
alert(response.authResponse.userID);
}
});
});
</script>
<img id="login" src="images/login.png" alt="" />
</body>
</html>
The above code works well when the user hasn't authenticated the app before. So when a user clicks the login button and the user accepts the login, the user id is returned successfully and the session will stick well when the use closes and reopens the app.
The problem lies when the user uninstalls the app and reinstalls again. When they click the login button, the login dialog will open quickly and close again as the user is already authenticated in the app. The user id and access token should return in the response like the regular javascript api of Facebook. Instead the second function which is failure will be returned with the following error:
session was closed and was not closed normally
I tried to logout the user but I got the following error:there is no session initiated...
Is there any solution for this?
Phonegap/Cordova facebook login not working when already connected
Aucun commentaire:
Enregistrer un commentaire