anvilresearch / connect-js

Anvil Connect JavaScript client for web browsers
http://anvil.io
MIT License
15 stars 11 forks source link

popup does not work on IOS #4

Closed henrjk closed 9 years ago

henrjk commented 9 years ago

This is with IOS version 8.2 (on IPad 2nd gen).

I tried using the display popup mode from the angular example (https://github.com/anvilresearch/connect-example-angularjs, see https://github.com/henrjk/connect-example-angularjs/blob/tryit/README.md).

To enable testing from my devices I am using grunt serve of the example while changing the hostname to 0.0.0.0 here). This allows to access the page with the private IP address of my dev machine in my home network. I configured the anvil-connect server so that callbacks and auth server also use that private IP address.

This works fine from the desktop and also on an Android Nexus 4, with Android 4.4.4 and Chrome 43.0.2357.93.

However when I touch SignIN on mentioned IPad nothing happens. The behaviour is the same in both Chrome (43.0.2357.61) and Safari (from User-Agent: Version/8.0 Mobile/12D508 Safari/600.1.4).

Earlier I had made some changes in the anvil-connect.angular.js to see how opening a new tab would work instead of reloading the URL in display page mode. As this had worked fine I suspected that the problem was the popup() function

Indeed when I comment out the || $document.documentElement.clientWidth and || $document.documentElement.clientHeight the popup works.

I have not yet actually debugged into this.

This is not directly related but I mention it as the resolution might be affected by this. I believe a display page mode which is presented in a new tab is a valid option also which makes more sense to me in a single page app then a page reload.

henrjk commented 9 years ago

Connected Safari on Mac with IPad as described at stackoverflow.

Observed that $window screenX, screenLeft, screenY, screenTop, outerWidth and outerHeight were all 0.

Found this error in console:

[Error] Error: undefined is not an object (evaluating '$document.documentElement.clientWidth')
popup@http://192.168.0.114:9000/bower_components/anvil-connect/anvil-connect.angular.js:199:71
authorize@http://192.168.0.114:9000/bower_components/anvil-connect/anvil-connect.angular.js:502:52
signin@http://192.168.0.114:9000/scripts/app.js:101:22
http://192.168.0.114:9000/bower_components/angular/angular.js:10567:26
http://192.168.0.114:9000/bower_components/angular-touch/angular-touch.js:438:21
$eval@http://192.168.0.114:9000/bower_components/angular/angular.js:12412:28
$apply@http://192.168.0.114:9000/bower_components/angular/angular.js:12510:28
http://192.168.0.114:9000/bower_components/angular-touch/angular-touch.js:437:19
dispatch@http://192.168.0.114:9000/bower_components/jquery/dist/jquery.js:4435:14
handle@http://192.168.0.114:9000/bower_components/jquery/dist/jquery.js:4121:33
    (anonymous function) (angular.js, line 9778)
    (anonymous function) (angular.js, line 7216)
    $apply (angular.js, line 12512)
    (anonymous function) (angular-touch.js, line 437)
    dispatch (jquery.js, line 4435)
    handle (jquery.js, line 4121) 

Further poking shows that $document.documentElement is undefined.

Next debugged this on a desktop Chrome. There $window.outerWidth and $window.outerHeight were 1870 and 1058. In:

        width = $window.outerWidth || $document.documentElement.clientWidth
        height = $window.outerHeight || $document.documentElement.clientHeight

$document.documentElement is only evaluated if outerWidth or outerHeight are 0 which leads then to the exception causing the error.

On a side note I believe there is no way to see console errors on IOS 8.2 except through the connected desktop Safari.

henrjk commented 9 years ago

See https://github.com/anvilresearch/connect-js/pull/5

christiansmith commented 9 years ago

Merged #5. Does this resolve #4 completely for you?

henrjk commented 9 years ago

One could argue that for IOS all the popup calculation do not really apply. However at the moment I haven't seen any problems but of course there is no automated test coverage so that is perhaps deceiving.

In general I think there should be another integration mode which opens the login in a different tab not a popup similar to how this behaves on IOS. But this is a different issue #6.

I am closing this one.