PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 16, 2022

[FIXED] How to logout with FBSDKLoginButton? (Weird error since Facebook assume I am logged in)

 July 16, 2022     facebook-ios-sdk, facebook-login, firebase, ios, swift     No comments   

Issue

When I login through FBSDKLoginButton but the user has authenticated his account with another provider (such as Twitter or Google), I show him/her an error. The problem is that if the user clicks in the Facebook Login button again, the following is shown:

enter image description here

I call the FBSDKLogin tap from my custom button and the callback returns with the error, which makes all the more confusing.. If Facebook recognizes the error in authenticating, why does it show a logout dialog?

@IBAction func facebookLogin(_ sender: Any) {
    fbLoginButton.sendActions(for: .touchUpInside)
}

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
    if let error = error {
        // How can I perhaps solve the problem here calling __.logOut()?
        print(error.localizedDescription)
        return
    }

    if let curr = FBSDKAccessToken.current() {
        let credential = FacebookAuthProvider.credential(withAccessToken: curr.tokenString)
        firebaseLogin(credential: credential)
    }
}

Solution

You will have been signed in via the FBSDKLoginManager as well.

Just logout using FBSDKLoginManager().logOut() when you sign out of Firebase.



Answered By - Callam
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing