ios - How Do I save the user's image fetched from fbprofilepictureview using the Facebook SDK -
so i'm implementing facebook login button in ios app i'm working on, i'm trying save user's profile picture that's accessed using line;
self.profilepicture.profileid = user.id;
i haven't had luck storing image use elsewhere in app. have tried number of methods including approach
imageurl=[nsstring stringwithformat:@"https://graph.facebook.com/%@/picture?redirect=true", user.username];
any welcome!
you need use user.objectid
, not user.username
.
you can use drop-in replacement fbprofilepictureview, dbfbprofilepictureview. exposes imageview readonly property. using that, code this...
self.profilepicture.completionhandler = ^(dbfbprofilepictureview* view, nserror* error){ if(error) { view.showemptyimage = yes; nslog(@"loading profile picture failed error: %@", error); } else { uiimage *image = view.imageview.image; nsdata *imagedata = uiimagepngrepresentation(image); [imagedata writetofile:filename atomically:no]; } };
Comments
Post a Comment