Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23904] iOS10: Button listener takes two taps before responding for Facebook login

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-09-17T11:49:32.000+0000
Affected Version/sRelease 5.5.0
Fix Version/sRelease 5.5.1, facebook 5.2.7
ComponentsiOS
Labelsqe-5.5.0
ReporterEric Merriman
AssigneeHans Knöchel
Created2016-09-14T20:58:00.000+0000
Updated2016-09-22T21:51:02.000+0000

Description

Description:

While testing a fix for TIMOB-23890, I noticed that the button for login required two presses before I was presented with the Facebook login. Sample code is here:
var fb = require("facebook");
 
// Facebook Stuff
fb.initialize();
 
 
var win = Ti.UI.createWindow();
 
var fbloginbutton = Ti.UI.createButton({
    title: "Login with Facebook"
});
 
fbloginbutton.addEventListener("click", function() {
    fb.authorize();
});
 
win.add(fbloginbutton);
 
var lbl = Ti.UI.createLabel({
    color: "red",
    text: fb.loggedIn
});

win.open();

Steps to reproduce:

1) Create a new classic mobile project 2) Attach the Facebook module 3) Paste the sample code into app.js 4) Install and launch 5) Press the "Login with Facebook" button

Result:

Nothing happens - Until you press the button again.

Expected Result:

The Facebook login process begins

Comments

  1. Chee Kiat Ng 2016-09-14

    [~hansknoechel] as you have mentioned to me before, is this related to another ticket?
  2. Hans Knöchel 2016-09-14

    Well, I guess it's because our Ti.UI.Button reacts different to a click-event than other UI-components do. It's more a general behavior than specific to our ti.facebook module. If you feel that we want to change this behavior, I'd do some native comparisons.
  3. Ygor Lemos 2016-09-14

    I have been able to reproduce this on my app. Sometimes just tapping another Ti.Button on our login flow makes the Ti.Button for facebook login work. This makes fb.authorize() unusable for login (specially when you block the UI with a loader for preventing multiple taps on the fb login button). fb.authorize() is the only way to have custom facebook login buttons. Also, this is very hard (at least for us) to reproduce on the simulator as the button that calls the authorize method seems to always work, but on the device itself we've managed to reproduce it every time.
  4. Ygor Lemos 2016-09-14

    As a temp-fix/jerry-rig I've tried to add a setTimeout calling the fb.authorize() method again after 500 ms. This works for all the times in which I needed to tap the button again for login but sometimes when authorize() works at first call, it opens a second SFSafariViewController with the facebook login flow and mess up the login flow and callbacks on the app since I'm invoking authorize() 2 times. This is not a viable solution at all but may help you in debugging. Also I have noticed that after a successful facebook login on the app, the button always works normally if I logout and login again without killing the app. The issue returns if I logout and manually kill the app. For now we are unblocking the UI (removing a full screen loader after the user tap the Facebook login for the first time) so the user can tap again at his own will if the SFSafariViewController doesn't appear (which is far from optimal).
  5. Ygor Lemos 2016-09-16

    @Hans can we increase the priority of this issue? Is it being discussed for 6.0.0 ? Thanks.
  6. Hans Knöchel 2016-09-16

    Yes, I will investigate it in the upcoming sprint. I'm still wondering why that could be an issue. Is this also happening on iOS < 9? And how about older ti.facebook versions? I need as many environments as possible.
  7. Hans Knöchel 2016-09-16

    Just reproduced it, it's a valid issue! [~cng] Might even be considered for 5.5.1 *EDIT*: Found [this Stackoverflow post](http://stackoverflow.com/questions/39532132/blank-page-while-logging-in-with-facebook-sdk-on-ios-10) that has the exact same issue. So I guess the Safari-Dialog tries to pop up "too early" and since fromViewController is nil in our case, it doesn't get called. [~ygbr] Can I send you a custom build that you verify? Guess I have something.
  8. Ygor Lemos 2016-09-16

    @Hans sure, I can test it now. ps: I don't know why, but I can't mention anybody on appc Jira...
  9. Hans Knöchel 2016-09-16

    PR: https://github.com/appcelerator-modules/ti.facebook/pull/68 I will also cherry-pick the changes from [Kiat's PR](https://github.com/appcelerator-modules/ti.facebook/pull/67) for adjusted docs. [~ygbr] Please try [facebook-iphone-5.2.7.zip](https://www.dropbox.com/s/aj3diy7zxlx60z6/facebook-iphone-5.2.7.zip?dl=0), thanks!
  10. Chee Kiat Ng 2016-09-17

    CR and FT passed. PR merged. Can we have the back ports please.
  11. Hans Knöchel 2016-09-17

    PR (titanium_mobile): master: https://github.com/appcelerator/titanium_mobile/pull/8390 6_0_X: https://github.com/appcelerator/titanium_mobile/pull/8391 5_5_X: https://github.com/appcelerator/titanium_mobile/pull/8392
  12. Lokesh Choudhary 2016-09-22

    Verified the fix. The button listener now responds after the first click for facebook login. Closing. Environment: Appc Studio : 4.8.0.201609191928 Ti SDK : 6.1.0.v20160922115612, 6.0.0.v20160922115636, 5.5.1.v20160921190109 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.6 Appc NPM : 4.2.7 Appc CLI : 5.5.0 Node: 4.4.4 Iphone 6 : IOS 10 Iphone simulator 7 plus : IOS 10 Iphone 6 : IOS 9.3.5 Facebook module : 5.2.7

JSON Source