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!
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];
}
};