apache / cordova-plugin-inappbrowser

Apache Cordova InAppBrowser Plugin
https://cordova.apache.org/
Apache License 2.0
1.12k stars 2.15k forks source link

A HREF's are being ignored using WKWebView on iOS #592

Open jtibbles opened 4 years ago

jtibbles commented 4 years ago

Bug Report

Problem

What is expected to happen?

You should be able to click on an href and have it open in a new window.

What does actually happen?

Nothing. No errors but the a href link is completely ignored

Information

Using WKWebView. In config.xml I've added as much "allow-navigation", "access" and "allow-intent" links as possible:

`

<access origin="//*"/>
<access origin="tel:*" launch-external="yes"/>
<access origin="mailto:*" launch-external="yes"/>
<access origin="skype:*" launch-external="yes"/>
<allow-navigation href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-intent href="skype:*" />

`

I force WKWebView like this: `

<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
<preference name="AllowBackForwardNavigationGestures" value="false" />
<preference name="Allow3DTouchLinkPreview" value="false" />
<preference name="WKWebViewOnly" value="true" />
<preference name="UseSwiftLanguageVersion" value="4" />
<preference name="SwiftVersion" value="4.2" />`

Command or Code

Just build and test the app

Environment, Platform, Device

all ios devices

Version information

Cordova: Cordova Xcode 11

Checklist

  • [x] I searched for existing GitHub issues
  • [x] I updated all Cordova tooling to most recent version
  • [x] I included all the necessary information above
netomarchiori commented 4 years ago

I’m Experiencing the same issue with tel: links not working

RichardBoyder commented 4 years ago

any updates on this? Same here... tel: and href: seem to be ignored

harnemo commented 4 years ago

It's the same for me, but works if I for example use "http://www.facebook.com". But not most other links.

iamrsojitra commented 4 years ago

@jtibbles @netomarchiori @RichardBoyder @harnemo After research and read blogs and all I found a solution for tel: sms: mailto: geo: links after a day like change some code in plugins/cordova-plugin-inappbrowser/src/ios/CDVWKInAppBrowser.m file.

Existing if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"]) {

Replaced with if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"] || [[ url scheme] isEqualToString:@"tel"] || [[ url scheme] isEqualToString:@"sms"] || [[ url scheme] isEqualToString:@"mailto"] || [[ url scheme] isEqualToString:@"geo"]) {

And its working πŸ€ͺ 🀨 🧐 boom πŸ˜›

yogii commented 4 years ago

@vc-rakesh , I am making build through automation software like Jenkins . is it possible to change plugin file ?

iamrsojitra commented 4 years ago

@yogii Maybe you can copy plugin file using below tag in config.xml at an appropriate location.

OR you can fork plugin repository, make changes and add it to your package.json file 😊

<resource-file src="" target="" />

jtibbles commented 4 years ago

@jtibbles @netomarchiori @RichardBoyder @harnemo After research and read blogs and all I found a solution for tel: sms: mailto: geo: links after a day like change some code in plugins/cordova-plugin-inappbrowser/src/ios/CDVWKInAppBrowser.m file.

Existing if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"]) {

Replaced with if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"] || [[ url scheme] isEqualToString:@"tel"] || [[ url scheme] isEqualToString:@"sms"] || [[ url scheme] isEqualToString:@"mailto"] || [[ url scheme] isEqualToString:@"geo"]) {

And its working πŸ€ͺ 🀨 🧐 boom πŸ˜›

I did something similar to get it working. Your solution is probably better though :)

netomarchiori commented 4 years ago

@jtibbles @netomarchiori @RichardBoyder @harnemo After research and read blogs and all I found a solution for tel: sms: mailto: geo: links after a day like change some code in plugins/cordova-plugin-inappbrowser/src/ios/CDVWKInAppBrowser.m file. Existing if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"]) { Replaced with if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"] || [[ url scheme] isEqualToString:@"tel"] || [[ url scheme] isEqualToString:@"sms"] || [[ url scheme] isEqualToString:@"mailto"] || [[ url scheme] isEqualToString:@"geo"]) { And its working πŸ€ͺ 🀨 🧐 boom πŸ˜›

I did something similar to get it working. Your solution is probably better though :)

yes, you can algo add "whatsapp" as well as a couple other known URL schemes.

anmolghosh commented 4 years ago

Any update here?

AdriVanHoudt commented 4 years ago

This might be due to https://github.com/apache/cordova-plugin-inappbrowser/pull/600

jumamfa commented 3 years ago

When will this be fixed in this repo? It looks like a viable fix was produced and incorporated into subinkrishna's repo above, but for various reasons, it would be great if the official plugin repo could have this fix applied?

gregtzar commented 3 years ago

+1 wtf

tictacmobile commented 3 years ago

The patch above only worked for me after downloading the latest cordova-ios, ios 6.2.0-nightly.2020.10.27.cb20c9bb.

tel: and sms: hrefs were still giving the infamous "Unsupported url" message, though. My solution is to open my own page in the inAppbrowser and have the appropriate tel:, sms: and mailto: links there. In my app.js:

$(document).on('click', 'a[href^=mailto], a[href^=tel], a[href^=sms]', function(eb) { eb.preventDefault();

    var $this = $(this); 

   cordova.InAppBrowser.open(mobUrl + '/ios/ContactLinks.jsp?href='+ $this.attr('href'), '_blank', 'location=no'); 
});
fernandoghisi commented 3 years ago

You can just use the last version of InAppBrowser (4.1.0 for now), and open the external link* using "cordova.InAppBrowser.open" instead of "window.open". Also, include the "hidden=yes", like this (it fixed some problems in iOS):

cordova.InAppBrowser.open('https://www.google.com/', '_system', 'hidden=yes,location=yes');

*It also works with "mailto", "tel", "whatsapp"... for Android, you just have to allow the intent and give permissions in config.xml file, like this:

<access launch-external="yes" origin="tel:*" />
<access launch-external="yes" origin="mailto:*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />

Finally, if you want all page loads in your app to go through the InAppBrowser, you can simply hook "window.open" during initialization:

$ionicPlatform.ready(function () {
  if (ionic.Platform.isWebView()) {
    window.open = cordova.InAppBrowser.open;
  }
}
tictacmobile commented 3 years ago

Wonderful, Thank you!

Kind regards,

Carl Zetterberg

Den ons 9 dec. 2020 kl 19:50 skrev Fernando Ghisi <notifications@github.com

:

You can just use the last version of InAppBrowser (4.1.0 for now), and open the external link* using "cordova.InAppBrowser.open" instead of "window.open". Also, include the "hidden=yes", like this (it fixed some problems in iOS):

cordova.InAppBrowser.open('https://www.google.com/', '_system', 'hidden=yes,location=yes');

*It works also with "mailto", "tel", "whatsapp"... for Android, you just have to allow the intent and give permissions in config.xml file, like this:

Finally, if you want all page loads in your app to go through the InAppBrowser, you can simply hook "window.open" during initialization:

$ionicPlatform.ready(function () { if (ionic.Platform.isWebView()) { window.open = cordova.InAppBrowser.open; } }

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/apache/cordova-plugin-inappbrowser/issues/592#issuecomment-741975596, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL7HKDR5YMTCVFWGGYVFXWDST7BHPANCNFSM4J2BBNXQ .

jay34fr commented 3 years ago

@jtibbles @netomarchiori @RichardBoyder @harnemo After research and read blogs and all I found a solution for tel: sms: mailto: geo: links after a day like change some code in plugins/cordova-plugin-inappbrowser/src/ios/CDVWKInAppBrowser.m file.

Existing if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"]) {

Replaced with if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"] || [[ url scheme] isEqualToString:@"tel"] || [[ url scheme] isEqualToString:@"sms"] || [[ url scheme] isEqualToString:@"mailto"] || [[ url scheme] isEqualToString:@"geo"]) {

And its working πŸ€ͺ 🀨 🧐 boom πŸ˜›

Thx a lot my friend @vc-rakesh !!! πŸ‘πŸ»πŸ‘πŸ»πŸ‘πŸ»πŸ‘πŸ»πŸ‘πŸ»