Titanium JIRA Archive
Appcelerator Modules (MOD)

[MOD-1866] Facebook: Logout event does not seem to fire if multiple requests are made

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2016-07-18T10:45:37.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsFacebook
Labelscommunity
ReporterJayme Fishman
AssigneeChee Kiat Ng
Created2014-02-11T12:29:50.000+0000
Updated2016-07-18T10:45:37.000+0000

Description

I am using the Facebook module and button for authentication. I have event listeners for the login and logout activities. I am using the listeners to show or hide a button that allows you to publish to FB. It also has an alert tied to it i.e. alert("logged out");. The FB button works fine for the FIRST login and logout. Subsequent logouts do not seem to fire the eventlistener as the alert does not state "logged out" and the button remains visible. Is that a bug?

Comments

  1. Ritu Agrawal 2014-02-12

    I am curious why you need your own event listeners for login and logout activities. http://docs.appcelerator.com/titanium/latest/#!/api/Modules.Facebook.LoginButton The Login Button created by Modules.Facebook.createLoginButton. This is a Facebook-themed button that does not require a click event handler or any listeners. Click events on the button are automatically handled by the Facebook module. The button changes its label to reflect the current state of the Facebook session. For example, if the user is already logged in, this button will show "Logout".
  2. Jayme Fishman 2014-02-12

    The primary reason is to dictate the visibility of a button that allows you to post to FB. If logged in, show it, if not, don't. This is also consistent with your examples from the updated FB module found here: http://docs.appcelerator.com/titanium/latest/#!/api/Modules.Facebook (and shown below) where you encourage developers to listen for login and logout events. The lack of a click listener won't help with any application flow that is predicated on the logged status (in / out). As an update to this ticket I am using the button on a view. I can't tell from the documentation if that is contributing to the issue (I can't see why it would). I should also add that as an additional test I called the getLoggedIn status and could see states being returned consistent with what they should have been based on the FB button state. In other words, if I was logged out the FB button returns to the correct state and getLoggedIn shows false (the buttons appearance is correct for both states). However, the listener for the logout does not appear to fire. I think those event listeners are useful - unless there is another way to accomplish what I am trying to do without them. Examples Authorize Shows official Facebook dialog for logging in the user and prompting the user to approve your requested permissions. Listen for the module's login event to determine whether the request succeeded. var fb = require('facebook'); fb.appid = FACEBOOK_APP_ID; fb.permissions = ['publish_stream']; // Permissions your app needs fb.forceDialogAuth = true; fb.addEventListener('login', function(e) { if (e.success) { alert('Logged In'); } else if (e.error) { alert(e.error); } else if (e.cancelled) { alert("Canceled"); } }); fb.authorize(); Logout Logout the user and forget the authorization token. The logout event is fired after the user is logged out. fb.addEventListener('logout', function(e) { alert('Logged out'); }); fb.logout();
  3. Jayme Fishman 2014-02-12

    More information for this ticket. I have found that if I close the window with the Facebook button and re-open it the logout event listener will fire. However, it will not fire if I keep the window open. The window in question that contains the view container for the button is being opened in a modal state. Steps to replicate: 1. Make a window that launches another modal window from a UI control 2. Create the window that opens in modal mode from the first screen 3. Add a view 4. Add a "back" button that closes the modal window to the view 5. Add a FB button to the view 6. Add a button to the view with visibility set to fb.getLoggedIn. 7. Add event listeners for FB login and logout with code to change the visibility of the button to true if logged in and false if logged out. 8. Optional: add alert messages for "login" and "logout" to the FB event listeners. You should see that the logout listener will not fire unless you close the modal window and reopen it.
  4. Ritu Agrawal 2014-02-13

    Thank you for providing additional information and detailed steps. We would need a complete runnable test case to make sure that we can reproduce and diagnose the exact same problem you are encountering.
  5. Jayme Fishman 2014-02-13

    You mean you need me to code the steps to reproduce the issue and send you the code?
  6. Ritu Agrawal 2014-02-13

    Yes, please.
  7. Jayme Fishman 2014-02-13

    Sorry, forgot to post this earlier. It is pulled together from a another code base but I tested it and can replicate (you can ignore some of the names of the controls for that reason and any extra comments I may have forgotten to delete). Please tell me when you have downloaded the project from so I can delete it: https://www.dropbox.com/sh/zpc3vn5el2mtad4/PjUYiRZv3v Also please substitute the FB app ID for your own in the code and in the TIAPP.xml file. It should work as intended a few times. However, keep doing it with multiple login and logouts and you should notice the eventlistener seems to stop working.
  8. Ritu Agrawal 2014-02-14

    [~jaymefishman] Thanks for providing the sample test case. I have downloaded it. You can remove your project now.
  9. Jayme Fishman 2014-02-14

    Great, can you please confirm if you can replicate the issue when you run it?
  10. Jayme Fishman 2014-02-20

    Hello, just checking to see if you could replicate the error? It took me a bit of time to code the example and it is a blocking issue for me. Please let me know. Regards. Jayme
  11. Ritu Agrawal 2014-02-20

    Moving this ticket to engineering as I can reproduce the issue with the provided test case on iOS platform. Both Login and Logout events fire correctly first time but do not fire next time onward. If you close the window then Login and Logout events fire again but that is most likely because they are being treated as first login and logout.
  12. Jayme Fishman 2014-02-21

    Glad you could replicate. I think that is a big issue for the FB module.
  13. Jayme Fishman 2014-02-21

    One last question - I assume you don't know of a clever workaround for this do you? I can't think of one but would welcome a suggestion.
  14. Jayme Fishman 2014-02-26

    Do you have a projected fix date for this issue?
  15. Jayme Fishman 2014-02-27

    Just checking back on this as it does not look to have a priority assigned to it. However, it is a blocking functionality loss for the FB module.
  16. Jayme Fishman 2014-03-31

    Can I get an update on this issue? It has been pending since start of Feb and I don't think it has been started. Meanwhile, it really limits the use of the Facebook module.
  17. Hans Knöchel 2016-07-18

    Fixed in Ti.Facebook 5.0 and later.

JSON Source