Any way to get the name of iPhone user? Any way to get the name of iPhone user? ios ios

Any way to get the name of iPhone user?


Well you could go through all the contacts in the AddressBook and see if any of them are marked with the owner flag.

Just be aware that doing this will popup the "this app wants access to the address book" message. Also Apple isn't very keen on these kind of things. In the app review guide it is specified that an app can not use personal information without the user's permission.


You could use Square's solution:

  1. Get the device's name (e.g. "John Smith's iPhone").
  2. Go through the contacts on the phone and look for a contact named "John Smith".

JBDeviceOwner and ABGetMe will both do this for you.


You could use CloudKit. Following a snippet in Swift (ignoring errors):

let container = CKContainer.defaultContainer()container.fetchUserRecordIDWithCompletionHandler(    {        (recordID, error) in        container.requestApplicationPermission(            .PermissionUserDiscoverability,            {                (status, error2) in                if (status == CKApplicationPermissionStatus.Granted)                {                    container.discoverUserInfoWithUserRecordID(                        recordID,                        completionHandler:                        {                            (info, error3) in                            println("\(info.firstName) \(info.lastName)")                        }                    )                }            }        )    })

The above code was based on the code at http://www.snip2code.com/Snippet/109633/CloudKit-User-Info

to save folks time. in swift4:

    let container = CKContainer.default()    container.fetchUserRecordID(        completionHandler: {            (recordID, error) in            guard let recordID = recordID else {                return            }            container.requestApplicationPermission(                .userDiscoverability,                completionHandler: {                    (status, error2) in                    if (status == CKContainer_Application_PermissionStatus.granted)                    {                        if #available(iOS 10.0, *) {                            container.discoverUserIdentity(withUserRecordID:                                recordID,                                                           completionHandler:                                {                                    (info, error3) in                                    guard let info = info else {                                        return                                    }                                    print("\(info.firstName) \(info.lastName)")                            }                            )                        }                    }            }            )        }    )

however: CKUserIdentity no longer exposes either first or last name

So this answer no longer works.