Reputation: 10789
I have been looking around to no avail regarding suppressing the dialog box on a mobile device when clicking on a telephone link.
We have this requirement to replace the existing native dialog on iPhone and Android with a custom popup from our website.
We have HTML5 at our disposal but for one basic site we are not to use javascript (for lower powered WAP phones).
Is there a way to suppress the phone native dialog coming from the browser (safari, chrome, firefox? ) via HTML from my site?
Thanks
Upvotes: 1
Views: 3175
Reputation: 415
Not sure if this is the complete spec you're asking for ... as far as I can tell from having fought with this too off and on for many months, there is no way to directly suppress the dialer dialog if OS thinks it's a phone number clicked in a page in a standalone browser.
I recall that it broadcasts an intent with "Tel:..." in the data parm. Since the vendor's dialer watches for that, the most you could hope for is to have your own dialer listen for that event too ... but then android would popup that annoying "complete action with" dialog AND they'd have to click yours, which would then have to launch yet another dialer intent. (And would you then see your intercept dialer too ? )
As BigMacAttack points out, you could run it through webkit, change your tag to something other than "tel" and intercept that. Similarly, if the server pages could always be fed through a web-kit view, you could do what I did on couple of android and iOS apps:
// Android flavored
wv1.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
boolean dialMe = false;
if (url.indexOf("tel:") > -1) { // PHONE permissions in AndroidManifest
// see also DIAL_PHONE
dialMe = myCustomDialerPopup ( Uri.parse(url) ) ; // display YOUR msg.
if ( dialMe = true ) { // launch normal dialer
Intent i = new Intent( Intent.ACTION_DIAL, Uri.parse(url) ) ;
view.getContext().startActivity(i);
} else {
//// guess they don't want to call - oops marketing failed !
}
}
return true; // or false to stop navigation.
}
}
Upvotes: 0
Reputation: 4549
If you're use case allows you to avoid using the tel: link format, you could put the numbers in something else that looks like a link and then have your webpage treat them however you wish. And to avoid having the browser auto-add links to numbers it thinks are telephone numbers, add the following html tag to your document's <head>
(from the Safari Developer Library):
<meta name="format-detection" content="telephone=no">
Is this sufficient or is there more to your question that I'm not understanding?
UPDATE
With further clarification, it appears the desired result is to call up the native telephone dialer when a tel://
link is pressed, but simply suppress the user prompt that precedes the dialing.
According to RFC 3966: The tel URI for Telephone Numbers, Section 11 Security Considerations:
"Web clients and similar tools MUST NOT use the "tel" URI to place
telephone calls without the explicit consent of the user of that
client. Placing calls automatically without appropriate user
confirmation may incur a number of risks..."
So while it still may be possible that a parameter exists to suppress the alert, such as &confirmation=false
or &alert=no
, it is likely undocumented and different for each mobile OS. My guess would be that it doesn't exist.
Possible Workarounds
According to the iOS Developer Library:
"When a user taps a telephone link in a webpage, iOS displays an alert asking if the user really wants to dial the phone number and initiates dialing if the user accepts. When a user opens a URL with the tel scheme in a native application, iOS does not display an alert and initiates dialing without further prompting the user. However, a native application can be configured to display its own alert."
So if your use case allows you to embed the website in a UIWebView
and distribute it as an iOS app, suppressing the alert should be possible.
According to the Android Developer Docs:
"[Use of the Dialer] requires your application to request the following permission in your manifest: <uses-permission id="android.permission.CALL_PHONE" />
"
So again, if your use case allows you to embed the website in an android.webkit.WebView
and distribute it as an Android app, suppressing the alert appears to also be possible.
Upvotes: 1