12

I have tried to disable phone number detection in safari for my web app but it still shows 7 character strings comprised of numbers as phone numbers. I used the apple provided meta tag but no joy.

<meta name="format-detection" content="telephone=no">

Anyone else run into this problem and work around it?

Thanks.

Update: It looks like it does not detect phone numbers in safari but rather when I save the page as an icon and run it from the home screen.

shim
  • 9,289
  • 12
  • 69
  • 108
yodaisgreen
  • 2,310
  • 3
  • 22
  • 27
  • I'm having the issue too, but only randomly. iOS doesn't detect the phone number format all the time. Any thoughts on why that happens? – nikjohn Dec 17 '14 at 12:52
  • possible duplicate of [How to disable phone number linking in Mobile Safari?](http://stackoverflow.com/questions/226131/how-to-disable-phone-number-linking-in-mobile-safari) – Brian Rogers Jul 15 '15 at 04:53

5 Answers5

13

Are you loading this in a UIWebView? If so, you need to set the property for dataDetectorTypes. e.g:

webView.dataDetectorTypes = UIDataDetectorTypeNone

Valid detector types are here.

Search for UIWebView on apple's site for a description of how to set the property there.

-Kevin

Benjohn
  • 13,228
  • 9
  • 65
  • 127
Kevin Franklin
  • 187
  • 1
  • 11
6

We had a similar problem on our JQM/Cordova app. We had a calculator built into the app and whenever the amount was more than seven digits the data would be in blue with an underline underneath and when you click on the data a pop up appeared and gave you the option to call. We simply added the meta tag as described in the opening question & it worked.

Just adding some thought here in case anybody else has a similar issue with Safari detecting 7 stringed data as telephone numbers.

Boyds
  • 441
  • 7
  • 17
5

OK. After quite a bit of futzing I think I found a strange work around. The problem with using dataDetectorTypes is that it will disable phone number detection for the whole uiwebveiw.

After trying datadetectors="off" and x-apple-data-detectors="false" attribute on span and a tags I finally stumbled on something that seems to prevent phone number detection.

If I wrap my text in an a tag with an href="#" apple seems to leave it alone.

yodaisgreen
  • 2,310
  • 3
  • 22
  • 27
2

Try this Code,

webView.dataDetectorTypes = UIDataDetectorTypeNone;

This may help you.

Nithinbemitk
  • 2,710
  • 4
  • 24
  • 27
1

Try and add this to YourProjectAppDelegate.m

// ...

- (void)webViewDidStartLoad:(UIWebView *)theWebView 
{
    theWebView.dataDetectorTypes = UIDataDetectorTypeAll ^ UIDataDetectorTypePhoneNumber;    
    return [ super webViewDidStartLoad:theWebView ];
}

// ...

Did the trick for me..

Peter Smeekens
  • 664
  • 4
  • 9