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