3

I am working with titanium platform, when i implement SSO in iOS, it works great whether i do it for one time or many times, it works smoothly and perfect. but when i come to Android, it work for the first time but not after that. For example, i installed the test app on android and click on facebook login, it works for first time, but when i logged out and try to login with facebook again then it just shows the redirection to facebook app but app login doesn't happen, i tried many times and try many ways but its not working.

I have placed facebook login event listener in app.js and in somewindow.js i have facebook login button. i am doing some work after logging in facebook, means redirecting to some other window.

thanks in advance.

sundar nataraj
  • 8,524
  • 2
  • 34
  • 46
Rizh
  • 96
  • 3

2 Answers2

1

Actually the problem persist due to cache . we need to clear cache when you log out use below code it works fine

 Titanium.Facebook.appid = "XXXXXXXXXXXXXXXXXX";
 Titanium.Facebook.permissions = ['publish_stream', 'read_stream'];


   var fbButton =  Ti.UI.createButton({
    top: 68,
    width:290,
    height:52,
    backgroundImage:"images/login/facebook.png"
});


 fbButton.addEventListener('click', function() {
if(Titanium.Facebook.loggedIn){
    Titanium.Facebook.logout()
    return
}
 Titanium.Facebook.authorize();

  });




Ti.Facebook.addEventListener('login', function(e) {
if (e.success) {
    win.close()
} else if (e.error) {
    alert(e.error);
} else if (e.cancelled) {
    alert("Canceled");
}
 });

  Titanium.Facebook.addEventListener('logout', function(e) {
    var url = 'https://login.facebook.com';
    var client = Titanium.Network.createHTTPClient();
    client.clearCookies(url);
});
sundar nataraj
  • 8,524
  • 2
  • 34
  • 46
0

Use this flag Ti.Facebook.forceDialogAuth=false;