I'm using the Facebook integration of iOS to allow user to sign in with their Facebook account.
I encountered a problem getting the user's full name.
I'm creating an ACAccount
of type ACAccountTypeIdentifierFacebook
.
After some searching I found out this little snippet to get the full name:
// account is an ACAccount instance
NSDictionary *properties = [account valueForKey:@"properties"];
NSString *fullName = properties[@"fullname"];
I tested it, and it worked. It worked on several devices.
Then we've send it to our client, he installed it, and it didn't work.
After a few days of testing, I was able to get the error happening on an iPhone from a co-worker.
After a quick debug session, I found out that the fullname
key wasn't present. Instead there were two other keys, ACPropertyFullName
and ACUIAccountSimpleDisplayName
.
Now my code to get the full name is:
NSDictionary *properties = [account valueForKey:@"properties"];
NSString *nameOfUser = properties[@"fullname"];
if (!nameOfUser) {
nameOfUser = properties[@"ACUIAccountSimpleDisplayName"];
if (!nameOfUser) {
nameOfUser = properties[@"ACPropertyFullName"];
}
}
So my question is actually divided in three parts:
Is it possible for the same thing to happen with the
uid
key, and If so, what possible keys exist?Is there any other keys to get the full name?
Does the same thing happens on Twitter, or it always uses the same keys?
Thanks y'all.