Reproduce Step.
1. Copy the following code to app.js file.
var fb = require('facebook');
var win = Ti.UI.createWindow({
title : 'Login/Logout',
backgroundColor: "white"
});
//fb module listener
fb.addEventListener('login', function(e) {
if (e.success) {
alert('login from uid: ' + e.uid + ', name: ' + JSON.parse(e.data).name);
} else if (e.cancelled) {
// user cancelled
alert('cancelled');
} else {
alert(e.error);
}
});
fb.addEventListener('logout', function(e) {
alert('logged out');
});
var loginButton = fb.createLoginButton({
readPermissions : ['read_stream', 'email'],
height: 100,
width: 100,
top : 260
});
win.add(loginButton);
var CurrentStatus = Ti.UI.createButton({
title : 'Current Status',
top : 50,
width : 160,
height : 40
});
win.add(CurrentStatus);
CurrentStatus.addEventListener('click', function() {
if (fb.getLoggedIn()) {
alert("Current UID: " + fb.getUid());
} else {
alert('Not logged in.');
}
});
win.open();
2. Setting all the necessary key pair for facebook (ref: our doc)
3. Run the app.
Problem.
1. If you run it first time, it will be fine. Then if you click the same button to logout. Then click login again. You will not able to login another account. Always the same one.
2. Even you set the facebook account in device -> setting, it will not impact the result. Change the account in setting, does not help too.
Note.
Sometimes, clean the browser will help. But not all the time, not sure why.
Help advise.
[~sliang] please change the title to better indicate the problem
[~sliang] As discussed on Flowdock, I am 90 % sure that this is the native behavior of the Facebook SDK. As [~jvennemann] noted, the logout method is not used to logout the user from Facebook, but only from the current app that used the Facebook SDK. In detail that means that - as long as the user a) has the Facebook app installed or b) is logged into Facebook in Safari / native browser, the "xxxx already authorized