Cordova InAppBrowser is blank on iPad iOS 10

2019-09-12 06:34发布

问题:

This issue happens only on iPad with iOS 10.

When I try to use InAppBrowser with presentationstyle set to fullscreen , it pops up fine but when I tap on the Done button, I got a blank screen. Looks like it doesn't destroy itself properly.

I am using Cordova 6.4.0 and InAppBrowser plugin 1.6.1

回答1:

Not sure if this is applicable to you but I was also having an issue with a blank screen after tapping the Done button, but it was only happening in landscape. Still worth a shot though:

cordova-plugin-statusbar & cordova-plugin-inappbrowser apparently don't play nice together so try either deleting cordova-plugin-statusbar all together or add an event listener on exit:

openUrl(url) {
  let ref = cordova.InAppBrowser.open(url, '_blank', options);

  ref.addEventListener('exit', () => {
    StatusBar.hide();
    StatusBar.show();
  })
}

StatusBar.hide() is what fixed the issue for me.

EDIT: As noted by René, a blank column exists with the fix noted above. In order to completely fix the issue in both iPhone and iPad without having to remove the plugin, wrap the StatusBar.show() call inside a setTimeout of a second:

openUrl(url) {
  let ref = cordova.InAppBrowser.open(url, '_blank', options);

  ref.addEventListener('exit', () => {
    StatusBar.hide();

    setTimeout( () => {
      StatusBar.show();
    }, 1000)
  })
}

Thanks René!