ERR_UNKNOWN_URL_SCHEME error in mailto:, sms: and tel: links

  • 18
  • Question
  • Updated 3 years ago
  • Answered
We are opening an external website in Inappbrowser using window.open(url, "_blank"); . We cannot use _self/_system because we have to listen to event listeners and do some functions on various events happening on the external website.
It works fine for all cases but when special links like Mailto:, tel:, sms: etc comes, then the application shows a error page showing ERR_UNKNOWN_URL_SCHEME error. The dialer/mail client does open but in background the page changes to error page.
Can anyone please help here?
Photo of Atul Sharma

Atul Sharma

  • 8 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 18
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
Hi Atul,

Add this to config.xml for all URL types that are affected: <access origin="sms:*" launch-external="yes" /> 

-yiming
Photo of Atul Sharma

Atul Sharma

  • 8 Posts
  • 0 Reply Likes
We have already done this. It works on local files of phonegap app. But if an external website is opened in inappbrowser, then it does not work.
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
Hi Atul,

Are those external websites also whitelisted as well in config.xml?

-yiming
Photo of Atul Sharma

Atul Sharma

  • 8 Posts
  • 0 Reply Likes
Hi, Yes they are whitelisted and opening fine. The issue comes only when any special link like mailto: is clicked in them.
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
Can you post a screenshot of the error in the app?

-yiming
Photo of Vishwani

Vishwani

  • 5 Posts
  • 0 Reply Likes


I am getting the same error. I have attached a screenshot for the same. If we simply put a link <a href="sms://XXXXXX">link</a> in the app and then click on that link, it works fine and doesn't show any error. Probably because it gets opened using _system but if we open it like the way it has been described by Atul it gives an error.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
You need to whitelist those protocols, too. It will work, then.
Photo of Atul Sharma

Atul Sharma

  • 8 Posts
  • 0 Reply Likes
As mentioned in the first comment, they are whitelisted and still we see error page.
Photo of Vishwani

Vishwani

  • 5 Posts
  • 0 Reply Likes
I have whitelisted them in the config.xml:
<access origin="tel:*" launch-external="yes"/>
<access origin="tel://*" launch-external="yes"/>
<access origin="geo:*" launch-external="yes"/>
<access origin="mailto:*" launch-external="yes"/>
<access origin="sms:*" launch-external="yes"/>
<access origin="sms://*" launch-external="yes"/>
<access origin="smsto:*" launch-external="yes"/>
<access origin="market:*" launch-external="yes"/>


but it still doesn't work.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
You don't have these links in the external page's html, do you?
Photo of Atul Sharma

Atul Sharma

  • 8 Posts
  • 0 Reply Likes
Yes these are in external website. They work fine on any browser. Just phonegap Inappbrowser fails
Photo of Vishwani

Vishwani

  • 5 Posts
  • 0 Reply Likes
Yea they work in any browser for me too, but not in inappbrowser.
Photo of Vishwani

Vishwani

  • 5 Posts
  • 0 Reply Likes
I got the solution. Look into the InAppBrowser.java file and you would be handling urls inside the onPageStarted(WebView view, String url, Bitmap favicon) function.

Instead override the following function:

public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL,
Uri.parse(url));
startActivity(intent);
}else if(url.startsWith("http:") || url.startsWith("https:")) {
view.loadUrl(url);
}
return true;
}


I found the solution at http://stackoverflow.com/questions/43...

Hope it helps.
Photo of Atul Sharma

Atul Sharma

  • 8 Posts
  • 0 Reply Likes
Thanks a lot Vishwani. It worked great.
Photo of Vishwani

Vishwani

  • 5 Posts
  • 0 Reply Likes
:) Happy to help.
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
Modifying plugins is not for all of us. Especially not if you are (and I am) using PhoneGap Build and don't even have access to the plugins.

Is there a solution in that case?

Cheers,
Anders
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
This appears to be a plugin issue and not with the PhoneGap Build service. You're better off checking on the issue tracker if CB-8180 is still unresolved.

-yiming
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
Thanks.

I solved it temporarily by using _system where this works. I have a setting for choosing the embedded browser.
Photo of Gunit Loco

Gunit Loco

  • 1 Post
  • 0 Reply Likes
'_system', 'location=no'
Photo of Nuno Amaral

Nuno Amaral

  • 11 Posts
  • 0 Reply Likes
Hi,

I'm also having the same problem.

I am using Intel XDK + Cordova

I use the plugin "InAppBrowser" to open an external website that I developed with Framework7.

On the contacts have links tel: and mailto: but when I click appears the error page "err_unknown_url_scheme"

How can I solve this problem?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
If you are showing the external page in the inappbrowser window (nt in the browser app on the device), then the whitelist plugin has no effect.

However, the inappbrowser plugin has been updated very recently:
http://cordova.apache.org/news/2016/0...
Which version are you trying?
Photo of Nuno Amaral

Nuno Amaral

  • 11 Posts
  • 0 Reply Likes
I use version 1.1.0
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1.3.0 can now be used, together with PGB cli-6.0.0
(doesn't automatically mean that tel:/sms:-links will work now)
Photo of Nuno Amaral

Nuno Amaral

  • 11 Posts
  • 0 Reply Likes
The problem is that the page of contacts tel: and mailto: is an external website (window.open).

The plugin "InAppBrowser" will work on the external website?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
That's a strange question.
Do you mean "plugin Whitelist"?
Photo of Nuno Amaral

Nuno Amaral

  • 11 Posts
  • 0 Reply Likes
I've also added these tags in xml this and continues to show the error page "err_unknown_url_scheme".
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
What tags?
(If you want to post tags, wrap them in a CODE element, as described under "some HTML allowed")
Photo of Nuno Amaral

Nuno Amaral

  • 11 Posts
  • 0 Reply Likes
This tags:

<access origin="tel:*" launch-external="yes"/>
<access origin="mailto:*" launch-external="yes"/>
Photo of Ky Serey Vuth

Ky Serey Vuth

  • 1 Post
  • 0 Reply Likes
mailto can't work
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Not sure if they will be converted to intents within the new IAB browser window. Have you tried?
Photo of Nuno Amaral

Nuno Amaral

  • 11 Posts
  • 0 Reply Likes
I did not understand your question.

I'm no expert in English.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
What question?
"Have you tried?"?

Just build your app with cli-6.0.0 and the latest inappbrowser, and test it.
Photo of Nuno Amaral

Nuno Amaral

  • 11 Posts
  • 0 Reply Likes
Intel XDK only appears to me the CLI version 5.1.1 and 1.1.0 plugin InAppbrower
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
So, you are building locally? Not with Phonegap Build?
Photo of Awais Ali

Awais Ali

  • 1 Post
  • 0 Reply Likes
Alku
Photo of Charles Henning Jr.

Charles Henning Jr.

  • 1 Post
  • 0 Reply Likes
Stop contacting me !
(Edited)