ios - Facebook login for Swift project -


i prompting users sign in through facebook obtain profile picture app's profile. code have requesting facebook sign in:

func facebooksignin() {     //current user that's logged in sign view     let curruser = pfuser.currentuser()      //create facebook session     fbsession.openactivesessionwithreadpermissions(permission, allowloginui: true, completionhandler: {         (session, status, error) -> void in             fbrequestconnection.startformewithcompletionhandler {(connection, result, error) -> void in             if error == nil {                 if result != nil && result.objectid != nil {                     //create column in parse called "facebookid"                     curruser!.setobject(result.objectid string, forkey: "facebookid")                     curruser!.saveinbackground()                 }             }     } } 

it worked fine before turned app development mode public. now, every time click "sign in on facebook" button, takes me safari facebook page , says "error. not logged in: not logged in. please login , try again"

anyone have idea issue be? log in page doesn't prompt anymore.

i see trying implement facebook login using facebook , parse ios sdk. not sure if necessary use fbsession , fbrequestconnection login. there 2 ways go. first 1 use parse facebook utils process login. or implement login via facebook ios sdk. below can find code second option coupled user registration.

override func viewdidload(){     fbsdkprofile.enableupdatesonaccesstokenchange(true)     nsnotificationcenter.defaultcenter().addobserver(self, selector: "fb:", name: fbsdkprofiledidchangenotification, object: nil) // hi! have logged in! can profile picture in "fb" function (since fbsdkprofile.currentprofile() loaded asynchronously downloaded) }  @ibaction func loginwithfacebook(sender: anyobject) { // button login     let fbloginmanager = fbsdkloginmanager()     fbloginmanager.loginbehavior = fbsdkloginbehavior.web     fbloginmanager.loginwithreadpermissions(["email", "public_profile", "user_friends"], handler: {         (result: fbsdkloginmanagerloginresult!, error:nserror!) -> void in         if error == nil && result.token != nil {             // logged in         } else {             // process error         }     }) }  func fb(notif:nsnotification){ // access token has changed! have logged in or logged out     if fbsdkaccesstoken.currentaccesstoken() != nil { // logged in?         pffacebookutils.logininbackgroundwithaccesstoken(fbsdkaccesstoken.currentaccesstoken(), block: { // let`s login fb user parse (using acquired fb access token)             (user: pfuser?, error: nserror?) -> void in             if let user = user {                 if user.isnew { // user new? let`s register in parse                     let smallprofileimage = fbsdkprofile.currentprofile().imagepathforpicturemode(fbsdkprofilepicturemode.normal, size: cgsizemake(100, 100))  // // user profile picture in small size                     let bigprofileimage = fbsdkprofile.currentprofile().imagepathforpicturemode(fbsdkprofilepicturemode.normal, size: cgsizemake(600, 600)) // user profile picture in big size                     user.setobject("https://graph.facebook.com/\(smallprofileimage)", forkey: "smallprofileimage") // set user`s small image (link)                     user.setobject("https://graph.facebook.com/\(bigprofileimage)", forkey: "bigprofileimage") // set user`s small image (link)                     pffacebookutils.linkuserinbackground(user, withaccesstoken: fbsdkaccesstoken.currentaccesstoken()) // save user in parse                 }             } else {                 print("uh oh. there error logging in.")             }         })      }  } 

update: seems have figured out. go facebook dev portal page , choose app. on left side panel, select "settings". check app info , "bundle id" (if correct, replace one, save settings , put correct 1 in). if issue still present, please go facebook app main page , go through "get started facebook sdk" guide (and check if bundle identifier correct when prompted). also, in "client oauth settings" (advanced tab on top) thing have enabled client oauth login


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -