0

So I'm implementing the Facebook login button in an iOS app I'm currently working on, I'm trying to save the user's profile picture that's accessed using this line;

self.profilePicture.profileID = user.id;

I haven't had any luck storing that image for use elsewhere in the app. I have tried a number of methods including this approach

imageUrl=[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?redirect=true", user.username];

Any help is welcome!

Josh
  • 225
  • 2
  • 14

1 Answers1

1

You need to use user.objectID and not user.username.

You can also use my drop-in replacement for FBProfilePictureView, DBFBProfilePictureView. This exposes the imageView as a readonly property. Using that, your code would be something like this...

self.profilePicture.completionHandler = ^(DBFBProfilePictureView* view, NSError* error){
    if(error) {
        view.showEmptyImage = YES;
        NSLog(@"Loading profile picture failed with error: %@", error);
    } else {
        UIImage *image = view.imageView.image;
        NSData *imageData = UIImagePNGRepresentation(image);
        [imageData writeToFile:filename atomically:NO];
    }
};
combinatorial
  • 9,132
  • 4
  • 40
  • 58
  • user.profileID doesn't exist. EDIT: It does exist but it's user.objectID. Thanks!!! – Josh Aug 23 '14 at 16:34
  • If you could edit your answer to reflect that, I'll be happy to accept and give you your well deserved points :) – Josh Aug 23 '14 at 16:36