Hi @juan,
I built and ran this and wanted to share my results and observations. Bottom line, I didn’t experience any issues.
Running on iOS 6.1 with the Facebook app installed:
- I opened the app and tapped the Facebook button, which swapped to the Facebook app. I granted the app basic and publishing permissions. When it swapped back to the app, the Connected to Facebook popup displayed, as expected
- I then force quit the app and reopened it. I tapped the Facebook icon again, and it immediately showed the Connected to Facebook popup without swapping to the Facebook app
- So, everything worked fine
Running on iOS 6.1 without the Facebook app installed yielded the exact same flow as above, except the login screen was via Safari rather than the Facebook app. So again, everything worked fine.
Running on Android 2.2 with the Facebook app installed:
- I opened the app and tapped the Facebook button, which launched the Facebook login flow via native popups. I granted the app basic and publishing permissions. When I finished, the Connected to Facebook popup displayed, as expected
- I then exited the app by pressing the back key (which is how most users would quit an app) and reopened it. I tapped the Facebook icon again, and it immediately showed the Connected to Facebook popup, as expected
- I then force quit the app from the settings menu, reopened it, and tapped the Facebook icon. This time, it did briefly show a system activity indicator before showing the Connected to Facebook popup, but it wasn’t a particularly bad user experience
Running on Android 2.2 without the Facebook app installed:
- I opened the app and tapped the Facebook button, which launches a webview to present a Facebook login screen. I granted the app basic and publishing permissions. When I finished, the Connected to Facebook popup displayed, as expected
- I then exited the app by pressing the back key (which is how most users would quit an app) and reopened it. I tapped the Facebook icon again, and it immediately showed the Connected to Facebook popup, as expected
- I then force quit the app from the settings menu, reopened it, and tapped the Facebook icon. This time, it did open up a Facebook webview indicating that I’d already authorized the app, which is a poor user experience
So, what I’m seeing so far is that on Android without the Facebook app installed, the user experience isn’t ideal only in the situation when the user force stops the app from the settings menu (which they’d most likely do only if the app had crashed). In all the other cases, the experience was fine.
After each test, I deauthorized the app on Facebook so that I could re-experience the full login flow for the next test. Note that, in all my tests, I was already logged into my account on the Facebook app and in the browser. I used build 1202 for all of this.
As for the issue you mentioned when the you cancel the login flow and then get a “login” event next time around, one thing I noticed in your code is that you don’t call facebook.logout() if the listener receives a loginFailed or loginCancelled event. It’s been my experience that you do need to call facebook.logout() in this case. What you described sounds the same as what was discussed in this thread: http://forums.coronalabs.com/topic/33855-facebook-login-does-not-return-token-after-previous-login-was-cancelled/. I’d suggest you call facebook.logout() after a loginFailed or loginCancelled event and see if that resolves it.