Facebook - isLoggedIn() on app launch
I've noticed an error with the Facebook module's isLoggedIn() method.
When I re-start my app after having logged in to Facebook, my isLoggedIn() check returns false. However, on my settings screen the Facebook button is in the logged-in state (grey button with 'Logout' text).
Is there an error with this method and if so, is there a documented fix for it?
Thanks,
Sean
4 Answers
-
Anyone?? I know I'm not the only one experiencing this. It would be good to get some official clarification.
-
Anyone?? I know I'm not the only one experiencing this. It would be good to get some official clarification.
-
I'm working on a solution to this at the moment. So far I've found that you need to add a button to the window first. That must send a request to Facebook to check your login status because if you set a timeout and check if the user is logged in after a few seconds, you'll get loggedIn = true. The problem is that the login event doesn't fire this way.
Haven't looked into this in too much detail yet but this post may be useful:
http://developer.appcelerator.com/question/1481/tifacebookisloggedin-isnt-accurate -
I do this in the function were i check if i need to open my settings screen or i can just open the facebook window:
var fbButton = Titanium.Facebook.createLoginButton({ 'style':'wide', 'apikey':'apikey', 'sessionProxy':'sessionProxy' }); win.add(fbButton); win.remove(fbButton); Ti.API.info(Titanium.Facebook.isLoggedIn()); if(Titanium.Facebook.isLoggedIn()==false){ ... }
And it works but. it's a little cowboy codeing style :)