I am working on an iOS 5 app where i need to get user profile data after successful login.
For now I am getting a access token when user get successful login.
<
This is the method to get user profile picture:
//in your app delegate file configure "FBProfilePictureView" class
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[FBProfilePictureView class];
}
//in your header file
IBOutlet FBProfilePictureView *userPictureView;
@property (strong, nonatomic) FBProfilePictureView *userPictureView;
//here "userPictureView" is uiview not uiimageview
//in your .m file
-(void)setProfilePicture {
[FBSession.activeSession closeAndClearTokenInformation];
NSArray *permissions = [NSArray arrayWithObjects:@"email", nil];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
NSLog(@"\nfb sdk error = %@", error);
switch (state) {
case FBSessionStateOpen:
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection, NSDictionary *user, NSError *error) {
if (!error) {
self.userPictureView.profileID = [user objectForKey:@"id"];
}
}];
break;
case FBSessionStateClosed:
//need to handle
break;
case FBSessionStateClosedLoginFailed:
//need to handle
break;
default:
break;
}
}];
}