srkleiman
srkleiman

Reputation: 727

Cordova app external links not working on iOS

I have a Cordova app (built with PGB) where external link stopped working on iOS. The links work fine on Android and as a WebApp, just not iOS. I tried both UIWebView and WkWebView. This used to work fine on all platforms. I'm not sure when it broke (Cordova 6 or iOS 11). I use the whitelist plugin with:

<access origin="*"/>
<allow-navigation href="*" />
<allow-intent href="*" />

The CORS header is:

<meta http-equiv="Content-Security-Policy"
    content="default-src 'self' gap://ready file://* *;
    style-src * 'self' 'unsafe-inline' 'unsafe-eval';
    script-src * 'self' 'unsafe-inline' 'unsafe-eval';"
>

The links are all external. I don't need or want them in the app WebView. I'd prefer a separate instance of Safari. Do I need to use the inappbrowser plugin anyway?

Upvotes: 4

Views: 2853

Answers (2)

Kubwimana Adrien
Kubwimana Adrien

Reputation: 2531

This worked for me! Defining allow-navigation to allow embeds will break external links so to fix this, I had to install inAppBrowser plugin https://github.com/apache/cordova-plugin-inappbrowser and used js to open the links with cordova.InAppBrowser.open(href, '_system');

Upvotes: 1

jcesarmobile
jcesarmobile

Reputation: 53371

allow-navigation takes precedence over allow-intent, you will have to remove the allow-navigation entry or change it to only allow navigation to certain urls, not all.

Upvotes: 5

Related Questions