Search code examples
ioscordovaionic-frameworkios10inappbrowser

InAppBrowser does not open properly with iOS 10.2 (Xcode 8)


I've been using the cordova-plugin-inappbrowser plugin for a long time now and when I updated the software to 10.2.1 on my apple test devices the plugin no longs works properly. When I try to open the inappbrowser link nothings happens unless I click the home button and return to the app. This happens for the simulators as well as on real devices like ipad, iphone 5s, iphone 6 and iphone 7. it works fine on android devices just not the latest iOS.

Here's a list of everything i tried:

  • updated inappbrowser to latest version - 1.7.1
  • removed and reinstalled the plugin and ios platform
  • tried making a blank app with the inappbrowser plugin
  • tried changing the index.html meta tag to include gap:

    <meta http-equiv="Content-Security-Policy" content="default-src * &apos;self&apos; gap: ; script-src &apos;self&apos; &apos;unsafe-inline&apos; &apos;unsafe-eval&apos; *; style-src &apos;self&apos; &apos;unsafe-inline&apos; *; child-src &apos;self&apos; &apos;unsafe-inline&apos; *;">
    

I can't seem to find anything else to try as most posts I do find that have a similar issue haven't been answered.

Below is the relevant code to how the inappbrowser plugin was installed and is being used:

config.xml Structure

<widget>
  <content src="index.html"/>
  <access origin="*"/>
  <allow-navigation href="*"/>
  <preference/> 
  ...
  <feature name="StatusBar">
  ...
  </feature>
  <platform name="ios">
  ... icons and splash ...
  </platform>
  <plugin name="cordova-plugin-inappbrowser" spec="~1.7.1"/>
</widget>

Using plugin in Controller

$scope.showLink = function(url){
  var options = {
   location: 'yes'
  }
  $cordovaInAppBrowser.open(url, '_blank', options)
  .then(function(event){
    // success
    console.log('inappbrowser', event);
  })
  .catch (function(event) {
   // error
   console.log('inappbrowser error', event);
  });
};

$scope.openUrl = function(url) {
  window.open(url, '_blank', 'location=no');
};

I'm using ionic v1.7.14 , cordova: 6.2.0 and xcode 8


Solution

  • As suggested by CodeGems, in the comments, adding gap://ready to your Content-Security-Policy should fix the issue.