ios - Get Facebook Profile picture at Sign-up for Parse backend (Swift) -
i'm creating application parse backend service. users should able sign-up , login via facebook.
i did in following (works absolutely fine).
@ibaction func registerwithfacebook(sender: uibutton) { let permissions:[string] = ["user_about_me","user_relationships", "public_profile"] pffacebookutils.loginwithpermissions(permissions, { (user: pfuser!, error: nserror!) -> void in if user == nil { nslog("uh oh. user cancelled facebook login.") } else if user.isnew { nslog("user signed , logged in through facebook!") self.loaddata() self.performseguewithidentifier("initialtomain", sender: self) } else { nslog("user logged in through facebook!") self.performseguewithidentifier("initialtomain", sender: self) } }) } func loaddata(){ let request:fbrequest = fbrequest.requestforme() request.startwithcompletionhandler { (connection:fbrequestconnection!, result:anyobject!, error:nserror!) -> void in if error == nil{ if let dict = result as? dictionary<string, anyobject>{ let name:string = dict["name"] anyobject? string let email:string = dict["email"] anyobject? string println(name) pfuser.currentuser().setvalue(name, forkey: "username") pfuser.currentuser().setvalue(email, forkey: "email") pfuser.currentuser().save() } } } }
unfortunately wasn't able profile picture user who's signing up. how can that?
the picture publicly available via user id @ following url:
https://graph.facebook.com/user_id/picture
you can request various sizes:
https://graph.facebook.com/user_id/picture?width=300&height=300
Comments
Post a Comment