dpa99c / cordova-plugin-inappbrowser-popup-bridge

A fork of cordova-plugin-inappbrowser which adds Braintree's PopupBridge functionality to support PayPal payments
Apache License 2.0
22 stars 18 forks source link

On iOS setting hidden=true in the options of cordova.InAppBrowser.open makes the entire app un-clickable #2

Closed benhtn closed 4 years ago

benhtn commented 6 years ago

I'm submitting a ... (check one with "x"):

Bug report

Current behavior:

When firing a hidden inAppBrowser browser, the app reports the browser as having started, and continues running, but the entire UI is un-clickable - as if there is a layer over the top that is catching all click events.

Expected behavior:

The app should continue to behave as normal.

Steps to reproduce:

Using the example project, for iOS, set hidden=yes (lines 48-49): if( device.platform === "iOS" ) { iabOpts = 'location=no,toolbar=yes,hidden=yes'; Build for iOS, and click the button on the main app screen the browser. The browser is running but the app interface is completely un-clickable.

Environment information

Runtime issue

iOS build issue:



Other information: I first noticed this in my ionic project, which uses cordova-plugin-ionic-webview, however the same issue is exhibited on the native Cordova example project using cordova-plugin-wkwebview-engine.

Many thanks in advance!

dpa99c commented 6 years ago

Thanks for reporting this. From the symptoms you describe, this is a regression bug that had occurred before and I fixed, but has crept back in.

The production apps that I'm using this plugin in do open a hidden IAB, but they display a static loading animation until the target page has loaded, at which time the IAB Webview is shown. Hence there's no opportunity for the user to interact with the underlying Cordova Webview while the IAB Webview is hidden, which is why I wouldn't have noticed this in regression testing.

I'm on holiday for the next couple of weeks, so probably won't have time to look into it, but in the meantime you might want to try out some of the older release versions of this plugin which shouldn't suffer from this issue. The fix required probably involves patching one of those older versions into the current latest version.

benhtn commented 6 years ago

Hi Dave, I confess I've not had time to work back through the commit history on this (and I am not an Objective C developer anyway so not sure I'd find it anyway). Have you any ideas? Many thanks Ben

dpa99c commented 6 years ago

Hi Ben, apologies for not getting back to you sooner.

In a nutshell, this is not a simple fix :-(

I developed this plugin out of necessity for a project that absolutely needed a solution to provide PayPal payments from an existing webpage driven by the Braintree JS SDK.

The only solution for iOS was to rewrite the inappbrowser plugin to use WKWebView, which was no mean feat - Objective C is by no means my first language either. Along the way, I encountered quite a lot of issues (as the commit history shows) related to content sizing, initial hiding then showing of the IAB, etc. Some of these issues were caused by bugs in my own implementation - I'm not a day-to-day native iOS developer and this plugin gets pretty heavily into the iOS native view hierarchy. There were also a few bugs which I'm pretty convinced were in the WKWebView implementation itself.

What I ended up doing was trading one issue off against another until I got an implementation that worked for our particular use case in the target app. That is now in production with approx. 200k monthly users across iOS and Android and is on the whole quite bug free.

However, trying to fix this one seemingly small issue actually tips over the whole apple cart: when I had a quick look at it, all the misery came flooding back. I've been trying to get Cordova to accept the bulk of my implementation (the actual "Popup Bridge" bit is only a fairly minor change - the bulk of the work is making the IAP work with WKWebView) back as a PR in the hope of some collaborators having the time/expertise to iron out these issues, but so far without much success.

Right now, I have a full-time contract on the go, an additional maintenance contract to fulfil, my own apps in the stores to maintain, and the rest of my Cordova plugins/Open Source stuff. So in reality, I really can't say when I'll have time to fix this properly; it's on the very edge of my native iOS skills/experience so really is going to be time-consuming to properly understand what's going on and fix it.

I'd like to be able to throw an experienced native iOS developer at it and get some assistance, but as I'm sure you're aware, most native iOS devs sniff and point their noses up at the mere mention of Cordova/Phonegap, so unless they were getting paid, it's pretty hard to convince them to help out.

benhtn commented 6 years ago

Thanks for looking into it and the detailed response Dave. I'll take that all back to the project I'm working on and see if there's any thoughts on budget for a fix. Although I doubt it short term - we'd need to prove we can get some revenue through the door.

For anyone else stumbling on this the only work around we came up with was this:

        var initialLoad = true;
        inAppBrowserRef = cordova.InAppBrowser.open(cartURL, '_blank', 'hidden=yes');
        inAppBrowserRef.addEventListener('loadstop', function() {
            if (initialLoad && $ionicPlatform.is('ios')) {
                inAppBrowserRef.show();
                inAppBrowserRef.hide();
            }
            initialLoad = false;
        }

Which has the side-effect on iOS of seeing the browser briefly show and hide whenever it is (re)started.

dpa99c commented 4 years ago

resolved by rebase onto cordova-plugin-inappbrowser@4 as cordova-plugin-inappbrowser-popup-bridge@4