I am launching a new iOS Swift application and want to use FirebaseUI Auth. Here is a link to the docs that talk about this in the Drop-in authentication solution Firebase Auth . FirebaseUI Auth for Android was very simple and easy. It seems that the iOS examples are out of date, as the API seems to have changed a lot between versions. It looks like they are on version 3.1 .
The directions are also a bit bare: https://github.com/firebase/FirebaseUI-iOS
Can someone please help me and provide an example of AppDelegate and ViewController for logging into facebook and google?
I am using Xcode 8.3, Swift 3.
Podfile:
# Uncomment the next line to define a global platform for your project platform :ios, '9.0' target 'Project' do
Here is my AppDelegate
import UIKit import CoreData import Firebase import FirebaseAuthUI import FirebaseAuth import GoogleSignIn import FBSDKLoginKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Here is my ViewController
import UIKit import Firebase import FirebaseAuth import FirebaseAuthUI import FirebaseDatabaseUI import FirebaseGoogleAuthUI import FirebaseFacebookAuthUI import FBSDKCoreKit import FBSDKLoginKit class ViewController: UIViewController, FUIAuthDelegate { var kFacebookAppID = "111111111111111" override func viewDidLoad() { super.viewDidLoad() //FIRApp.configure() checkLoggedIn() } func checkLoggedIn() { FIRAuth.auth()?.addStateDidChangeListener { auth, user in if user != nil { // User is signed in. } else { // No user is signed in. self.login() } } } func login() { let authUI = FUIAuth.defaultAuthUI() let facebookProvider = FUIGoogleAuth() let googleProvider = FUIFacebookAuth() authUI?.delegate = self authUI?.providers = [googleProvider, facebookProvider] let authViewController = authUI?.authViewController() self.present(authViewController!, animated: true, completion: nil) } @IBAction func logoutUser(_ sender: AnyObject) { try! FIRAuth.auth()!.signOut() } func authUI(_ authUI: FUIAuth, didSignInWith user: FIRUser?, error: Error?) { if error != nil { //Problem signing in login() }else { //User is in! Here is where we code after signing in } } }
source share