简体   繁体   中英

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

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM