I have an app which uses FB login inside the app to gather a users FB id which I use to create a link to their FB page like so:
@IBAction func saveFacebookDidTap(_ sender: Any) {
if sharingFacebook == false {
if FBSDKAccessToken.current() == nil {
print("no token")
}
login.logIn(withReadPermissions: ["public_profile"], handler: { (result, error) -> Void in
if error == nil && !(result?.isCancelled)! {
let fbloginresult : FBSDKLoginManagerLoginResult = result!
if fbloginresult.grantedPermissions.contains("public_profile") {
print("success")
let parameters = ["fields" : "id"]
if FBSDKAccessToken.current() != nil {
self.facebookButton.setTitle("Remove Facebook from your Profile", for: [])
self.sharingFacebook = true
FBSDKGraphRequest(graphPath: "me", parameters: parameters).start { (connection, result, error) -> Void in
if error != nil {
return
}
let data:[String:AnyObject] = result as! [String : AnyObject]
if let id = data["id"] as? NSString{
//do stuf with the id
I also allow the user to remove this FB link like so:
else {
self.sharingFacebook = false
self.facebookButton.setTitle("Add Facebook to your Profile", for: [])
FBSDKLoginManager().logOut()
}
I am having an issue with the FB login page. When the user clicks to add their FB, I am seeing a page that says "You previously logged in to "app name" with Facebook. Would you like to continue?" I am not seeing the fields which let me enter email and password. Any ideas what I could be missing?
I was having a similar problem. The cause is explained here: How to completely Logout of Facebook SDK Auth in iOS App
I was able to get around this issue by setting the Login Behavior, i.e.
LoginManager.setLoginBehavior('web');
before initiating login.
I had this issue when Safari was caching the Facebook login credentials. Went to Settings...Safari...Clear History and Data. Solved it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With