I'm creating a registration for my iPhone application and would like to add the ability to guess the phone's default name and email to minimize the amount of typing for the user. What APIs could be used to autofill this information (UITextField, not safari)?
Asked
Active
Viewed 644 times
3 Answers
2
I don't think the API gives you access to this information. That would be a huge privacy hole.

Jason
- 86,222
- 15
- 131
- 146
-
1Since application are approved by Apple how would this be a privacy hole? After all you do have access to their address book. – Kendall Hopkins Mar 24 '11 at 03:55
-
If you install an app that can figure out your name, e-mail and phone, then it can submit them to third parties. – Jason Mar 24 '11 at 13:10
-
"If" is the keyword. I've already found a few ways to get the [name](http://stackoverflow.com/questions/5414170/help-user-registration-by-using-iphone-default-email-and-name/5414856#5414856) and [phone](http://stackoverflow.com/questions/193182/programmatically-get-own-phone-number-in-iphone-os). Since those API already exist and it hasn't caused a massive problem with security on that data, I assume Apple does a pretty good job at protecting those API's from slipping through the approval process. – Kendall Hopkins Mar 24 '11 at 17:44
-
Interesting. I'm surprised you can access that data. I wonder if doing that will get you flagged during review? – Jason Mar 25 '11 at 01:43
2
I think I might have found a questionable way of using Apple's defaults and UIDevice API that allows for likely discovering of a user's Full Name.
Since many users probably don't change the default device name, we can check to see if it matches the default format and strip out the Full name of the person.
NSString * tryToGuessFullName() {
NSMutableArray * deviceNamePieces = [NSMutableArray arrayWithArray:[[UIDevice currentDevice].name componentsSeparatedByString:@"’"]];
if( [deviceNamePieces count] >= 2 ) {
NSString * possibleSuffix = [deviceNamePieces lastObject];
if( [possibleSuffix isEqualToString:@"s iPhone"] || [possibleSuffix isEqualToString:@"s iPad"] || [possibleSuffix isEqualToString:@"s iPod"] ) {
[deviceNamePieces removeLastObject];
return [deviceNamePieces componentsJoinedByString:@"’"];
}
}
return nil;
}

Kendall Hopkins
- 43,213
- 17
- 66
- 89
-
That's one sly way of doing it. :) Might work as a best-effort approach at least. I've changed my device name anyway, unpleasant to shout my real name to all other commuters when tethering on the train. – Ciryon Jan 09 '13 at 06:55
0
You could ask the user to select a contact from the address book (presumably them) to help along this process. In doing so, you may get address info too.

jer
- 20,094
- 5
- 45
- 69