Add a Facebook LoginButton on Mainstoryboard
facebook-login, firebase, firebase-authentication, ios
Solution
If you want to add Facebook Button to your project, you have to add a `UIButton` to your `ViewController` and then change its class to `FBSDKLoginButton`. Check the image below:
If you want to customize it, create a class and extend `FBSDKLoginButton`, and then instead of adding `FBSDKLoginButton` in your custom class, insert your customized class.
Problem
we've used Cocoapods to install FacebookCore and FacebookLogin, however, we want to use the LoginButton in our Mainstoryboard. We've made a view with class `LoginButton` and module `FacebookLogin` In our viewcontroller we assign the delegate to the button as follow: ``` @IBOutlet weak var facebookLogin: LoginButton! override func viewDidLoad() { user = FIRAuth.auth()?.currentUser self.ref = FIRDatabase.database().reference() if user != nil { let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home") self.present(vc!, animated: true, completion: nil) } //Facebook login self.facebookLogin.delegate = self } ``` We've also implemented the `loginButtonDidCompleteLogin` and `loginButtonDidLogOut`but the button won't show when we start-up the emulator.