Home Facebook is returning anything when recompiling with iOS9
Reply: 1

Facebook is returning anything when recompiling with iOS9

Saty
1#
Saty Published in 2015-12-24 12:25:10Z

I was having issue with iOS 8.4 compilation with Facebook SDK so I upgraded to Xcode 7.1 and using Facebook Sdk 4.6. I am following the below code for the login. It's giving me weird experiences, sometimes, it opens up SafariViewController, some times it opens both popup view and SafariViewController and sometimes it opens up only pop -up view.

In Any of the case, I try to login I don't get data in neither

func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!)

or in

fbLoginManager.logInWithReadPermissions(["email"], fromViewController: self, handler: { (result, error) -> Void in if (error == nil)

I have followed and added the NSTransportExceptions too

Codes

In ViewDidload I defined this

    fblogin.delegate = self
    fblogin.readPermissions = ["public_profile", "email", "user_friends"]

fblogin is the loginButton

@IBAction  func loginFb(sender:AnyObject)
{
    let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()
    fbLoginManager.loginBehavior = FBSDKLoginBehavior.Web
    fbLoginManager.logInWithReadPermissions(["email"], fromViewController: self, handler: { (result, error) -> Void in
        if (error == nil){
            let fbloginresult : FBSDKLoginManagerLoginResult = result
            if fbloginresult.grantedPermissions != nil { //Here we have to check that the set contains value or not
                if(fbloginresult.grantedPermissions.contains("email"))
                {
                    self.getFBUserData()
                    //fbLoginManager.logOut()
                }
            }
        }
    })
}
func getFBUserData(){
    NSLog("Called")
    if((FBSDKAccessToken.currentAccessToken()) != nil){
        FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).startWithCompletionHandler({ (connection, result, error) -> Void in
            if (error == nil){
                self.dict = result as! NSDictionary
                print(result)

                print(FBSDKAccessToken.currentAccessToken().tokenString)
                //NSLog(self.dict.objectForKey("picture")?.objectForKey("data")?.objectForKey("url") as! String)
            }
        })
    }
}

I was having issue with Facebook is not returning data in didCompleteWithResult in iOS 9 so I upgraded to Xcode 7

Tomer Even
2#
Tomer Even Reply to 2015-12-29 07:31:03Z

In order to make a valid fields request they need to be without spaces e.g. "id,first_name,last_name,email"

About the switching to the Facebook app instead of showing SFSafariViewController you need to use any Facebook SDK before v4.6 in which they changed this

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.310199 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO