ios - Custom Facebook loginButton functions Swift 3 -


i'm trying create custom loginbutton, i've found lot of guides for. however, none of them updated swift 3, i've tried myself create functions. however, keep getting errors.

the first i'm getting ambiguous reference member login(_:completion:)

@ibaction func loginpressed(_ sender: anyobject) {     let fbloginmanager : loginmanager = loginmanager()     fbloginmanager.login(["public_profile", "email", "user_friends"], viewcontroller: self, completion: { (result, error) -> void in          if (error == nil){             let fbloginresult : fbsdkloginmanagerloginresult = result!             if fbloginresult.grantedpermissions != nil {                 if(fbloginresult.grantedpermissions.contains("email"))                 {                     self.getfbuserdata()                     fbloginmanager.logout()                 }             }         }      })  } 

the second i'm getting cannot convert value of type (_, _, _) -> void expected argument type (httpurlresponse?, graphrequestresult<graphrequest> -> void)

func getfbuserdata(){     if((accesstoken.current) != nil){         graphrequest(graphpath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).start({ (connection, result, error) -> void in              if (error == nil){                 //everything works print user data                 print(result)             }         })     } } 

the solution first problem following: no need add completion: word end of function. function should this:

fbloginmanager.login(["public_profile", "email", "user_friends"], viewcontroller: self) { result in     // handle result } 

make sure delete ) end of call.

the second problem has 2 parts. need update completion handler syntax, plus 1 of parameters has been removed. function should following:

graphrequest(graphpath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).start { (urlresponse, requestresult) in          if (error == nil) {        //everything works print user data        print(result)      } } 

also, tutorial facebook seems promising!

also, here link sdk on github, can take on samples project examples.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -