Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Square's iPhone app programmatically retrieve the user's contact information?

Tags:

ios

usability

When I install the Square app on a brand-new iPhone, it prepopulates my first name, last name, and e-mail into the signup fields. All I have to type is a password. That's really neat.

How does that work, and how does it know who I am? Is this using a privileged API? There's no programmatic way to get a user's name, AFAIK.

like image 284
Kyle Kaitan Avatar asked Mar 26 '12 19:03

Kyle Kaitan


1 Answers

I was actually curious about this too, so I checked it out myself earlier. It's a very clever trick. Here's how it works:

  • First, Square accesses the name of your iPhone. (This isn't a protected API.)

  • For most people, the default name of the phone is something along the lines of "Steve Smith's iPhone". A regular expression match is performed, parsing out "Steve Smith".

  • "Steve Smith" is then searched for in your contact list.

  • If an entry is found, it brings back the first/last names and the e-mail address for that contact. The signup form is prepopulated accordingly.

  • If an entry is not found, the signup form will stay blank. Likewise, if the name of your iPhone is something other than the default format -- even if it's just one character off -- the prepopulation mechanism won't fire.

You can prove that this works by changing the name of your iPhone to an arbitrary contact, as in "Dave Wilson's iPhone", and noticing that Dave Wilson's contact info will now be prepopulated.

like image 160
John Feminella Avatar answered Oct 26 '22 21:10

John Feminella