ravelinx ravelinx - 5 months ago 54
iOS Question

How to add facebook sdk login to an eureka swift form?

I am currently developing an iOS app with Swift, I had already downloaded facebok sdk login and also I am familiar with it. In the other hand I need to make custom table views so I downloaded Eureka framework to do this.

I have a table that asks the user for information in order to register a new account, the problem is that I need a facebook login option at the top of the table view, but I havent find a way to accomplish this. As the Eureka table view is added programmatically it can be seen in the storyboard so I need to find a a way and add the login button. Does anyone know how to do this? Thanks

Here is my table code:

private func addLoginForm() {
self.form +++ Section()
<<< TextRow() { $0.placeholder = "Name"
$0.tag = "name"
}
+++ Section()
<<< TextRow() { $0.placeholder = "Email"
$0.tag = "email"
}
+++ Section()
<<< PhoneRow() {$0.placeholder = "Phone"
$0.tag = "phone"
}
+++ Section()
<<< PasswordRow() { $0.placeholder = "Password"
$0.tag = "password"
}
+++ Section()
<<< ButtonRow() {
$0.title = "Login"
$0.onCellSelection { cell, row in

self.evaluate()

}.cellSetup({ (cell, row) in
cell.backgroundColor = UIColor(red: 114.0/255, green: 3.0/255, blue: 194.0/255, alpha: 1.0)
cell.tintColor = UIColor.whiteColor()
row.cell.height = {
return 65
}
})
}

}

Answer

I founded the solution by adding the facebook login at the header of a section in the form like this:

   form  +++ Section()
            {
                var header = HeaderFooterView<FBSDKLoginButton>(HeaderFooterProvider.Class)
                header.onSetupView = { (view: FBSDKLoginButton, section: Section) -> Void in
                     view.readPermissions = ["public_profile","email","user_friends"]
                     view.delegate = self
                }

                $0.header = header
        }

also you need to import FBSDKLoginKit and FBSDKCoreKit