8

Is there a method for getting the iPhone users phone number using HTML5/jQuery?

All I see is how to do this with the SDK.

EDIT:

So far the only thing I've found is on the initial install ask the user for their number and store it.

Phill Pafford
  • 83,471
  • 91
  • 263
  • 383

3 Answers3

14

I am pretty sure, that this is not possible. Imagine the security/privacy breach it would represent if any site could just retrieve the phone number of each visitor.

If you are developing a HTML5 & JS app with PhoneGap for example you can, using the according API: http://docs.phonegap.com/en/1.0.0/phonegap_contacts_contacts.md.html

meo
  • 30,872
  • 17
  • 87
  • 123
  • That's what I was thinking :( – Phill Pafford Apr 29 '10 at 14:58
  • there is a similar question here: http://stackoverflow.com/questions/2386011/read-gsm-number-from-iphone-through-javascript – meo Apr 29 '10 at 15:00
  • 1
    I wonder about questions like this. What possible legitimate reason could you have for collecting a phone number? I would think Apple would reject the app... at least I hope they would. – Michael Morrison Apr 29 '10 at 17:35
  • 3
    An HTML5 application is a Web Application accessible from a server and won't be accessible from AppStore, so Apple has nothing to say. – Cbe317 Apr 30 '10 at 17:44
  • 2
    HTML 5 based solutions can be non web solution applications too. WP8 is rumoured to have HTML5 applications (Metro apps). Phonegap also allows for HTML5 applications. Apple expose their own APIs to contacts which can be used with phonegap. So I would think they don't mind. – Dessus Jan 11 '12 at 01:51
  • @Dessus this is true, but you should mention it in the question if it is so. But i will add it to my answer – meo Jan 11 '12 at 09:20
  • @Michael Morrison: a legitimate reason: my users want to provide me with their phone numbers so that I can contact them. It is a poor experience to have users type in their phone number when the device already knows this number. The same logic applies to sharing location where the browser asks if the user wants to share this info and then allows access if granted. – TrevTheDev Oct 20 '14 at 10:14
  • @MichaelMorrison: Think What's App. Their method of associating user's phone numbers with What's App accounts was (imho) what made the app so popular. It can instantly tell you which of your existing contacts also use What's App, because you have the phone numbers of your contacts and they know the phone numbers of their users. They could never have done that with regular user names. – Stijn de Witt May 12 '15 at 22:59
  • One other legitimate use could be whitelisting admin access to HTML5 apps based on phone number – ForrestLyman Nov 19 '16 at 16:45
9

There is a Draft from W3C on Device API. This API will provide access (submitted to user permission) to Tasks, Contacts, Calendar, Camera, Microphone, Messaging Service, Communication Log, System Information (device information, battery level, network status, ...),... But it is not yet implmented in any browser.

Because of a big expectation, these APIs will probably be implemented very quickly in WebKit (base of iPhone and Android browsers). Mozilla is working on a draft implementation of Contact API with the Contact AddOn

Cbe317
  • 1,229
  • 1
  • 8
  • 9
  • Ha! Ask and you shall receive! I just posted a how-cool-would-it-be about this on @Jeena's post. – jedmao Jul 17 '10 at 17:44
3

You could just ask the user:

var phone_number = prompt("Please enter your phone number:");
Jeena
  • 2,172
  • 3
  • 27
  • 46
  • I could but this would not be the best user experience, would like to capture this behind the scenes if possible – Phill Pafford Apr 29 '10 at 14:52
  • 1
    This is your only real option at this time. Don't you think it may be a HUGE privacy issue if any site I browse to on my phone could get my phone number without me giving it to them? – jamone Apr 29 '10 at 17:34
  • 1
    Even if you technically *could* capture the phone number behind the scenes I would still use @Jeena's approach. What you're trying to do is completely ridiculous for all the reasons previously stated and I'm entirely disgusted that anyone would think to do such a thing. Actually, I think it would be pretty awesome if there were such a function, but if the iPhone had a built-in method to prompt the user with a security warning, kinda' like the Microsoft Windows Vista/7 UAC prompt. That way, there might be some useful applications for it without the security/privacy issues. – jedmao Jul 17 '10 at 17:42