Я разрабатываю приложение, используя apache cordova/phonegap. Моя проблема заключается в том, что когда пользователь выходил из facebook с родного приложения facebook, в моем приложении статус всегда connected
, когда я звоню FB.getLoginStatus
. Что я делаю неправильно? Как я могу определить, вышел ли пользователь из собственного приложения facebook?FB.getLoginStatus response.status всегда подключен?
<?xml version="1.0" encoding="UTF-8" ?>
<!<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>yourFREEtree</title>
<meta http-equiv="content-type" content="application/xhtml+xml" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" media="all and (orientation:portrait)" href="style.css">
</head>
<body>
<div id="data">loading ...</div>
<div id="fb-root"></div>
<!-- cordova -->
<script src="cordova.js"></script>
<!-- cordova facebook plugin -->
<script src="cdv-plugin-fb-connect.js"></script>
<!-- facebook js sdk -->
<script src="facebook-js-sdk.js"></script>
<script>
<!-- These are the notifications that are displayed to the user through pop-ups if the above JS files does not exist in the same directory-->
if ((typeof cordova == 'undefined') && (typeof Cordova == 'undefined')) alert('Cordova variable does not exist. Check that you have included cordova.js correctly');
if (typeof CDV == 'undefined') alert('CDV variable does not exist. Check that you have included cdv-plugin-fb-connect.js correctly');
if (typeof FB == 'undefined') alert('FB variable does not exist. Check that you have included the Facebook JS SDK file.');
FB.Event.subscribe('auth.login', function(response) {
});
FB.Event.subscribe('auth.logout', function(response) {
//alert('auth.logout '+response.status);
});
FB.Event.subscribe('auth.sessionChange', function(response) {
//alert('auth.sessionChange '+response.status);
});
FB.Event.subscribe('auth.statusChange', function(response) {
FB.getLoginStatus(function(response) {
// this will be called when the roundtrip to Facebook has completed
alert(response.status);
//alert(response.authResponse.accessToken);
}, true);
});
document.addEventListener('deviceready', function() {
try {
//alert('Device is ready! Make sure you set your app_id below this alert.');
FB.init({ appId: "{MYAPPID HERE}", nativeInterface: CDV.FB, useCachedDialogs: false });
document.getElementById('data').innerHTML = "";
} catch (e) {
alert(e);
}
}, false);
</script>