Kendall Hopkins
Kendall Hopkins

Reputation: 44104

Help user registration by using iPhone default email and name

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)?

Upvotes: 1

Views: 656

Answers (3)

Kendall Hopkins
Kendall Hopkins

Reputation: 44104

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;
}

Upvotes: 2

jer
jer

Reputation: 20236

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.

Upvotes: 0

Jason
Jason

Reputation: 89102

I don't think the API gives you access to this information. That would be a huge privacy hole.

Upvotes: 2

Related Questions