What you're doing there with the valueForKey:@"properties"
call is accessing a private property and it will get your app rejected by Apple.
If your project is an iOS 7 project, you can use a new property on the ACAccount
class called userFullName
. From ACAccount.h
:
// For accounts that support it (currently only Facebook accounts), you can get the user's full name for display
// purposes without having to talk to the network.
@property (readonly, NS_NONATOMIC_IOSONLY) NSString *userFullName NS_AVAILABLE_IOS(7_0);
Alternatively, you can use the Graph API to query the current user using the Social framework:
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:[NSURL URLWithString:@"https://graph.facebook.com/me"]
parameters:nil];
request.account = account; // This is the account from your code
[request performRequestWithHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error == nil && ((NSHTTPURLResponse *)response).statusCode == 200) {
NSError *deserializationError;
NSDictionary *userData = [NSJSONSerialization JSONObjectWithData:data options:0 error:&deserializationError];
if (userData != nil && deserializationError == nil) {
NSString *fullName = userData[@"name"];
NSLog(@"%@", fullName);
}
}
}];