새로운 iOS Swift 애플리케이션을 시작하고 FirebaseUI Auth를 사용하려고합니다. 다음은 문서에 대한 링크이며 여기서는 Drop-in authentication solution
Firebase Auth 아래에 대해 설명합니다. Android 용 FirebaseUI Auth는 매우 간단하고 쉽습니다. API가 버전간에 크게 변경된 것으로 보아 iOS 예가 오래된 것 같습니다. 버전이 3.1 인 것 같습니다.Firebase UI Auth Provider iOS Swift 예제
방향은 또한 조금 베어 있습니다 https://github.com/firebase/FirebaseUI-iOS
누군가가 로그인 나를 도와와 페이스 북에 대한 예를 AppDelegate에와의 ViewController를 제공하고 구글시겠습니까? 내가 엑스 코드 8.3을 사용하고
, 스위프트 3.
Podfile : 여기
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'Project' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'FirebaseUI', '~> 3.1'
pod 'Firebase/Core'
pod 'Firebase/Database'
pod 'Firebase/Crash'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
pod 'GoogleSignIn'
pod 'FBSDKLoginKit'
target 'ProjectTests' do
inherit! :search_paths
# Pods for testing
end
target 'ProjectUITests' do
inherit! :search_paths
# Pods for testing
end
end
은 여기 내 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 {
// Override point for customization after application launch.
FIRApp.configure()
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
}
내의 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
}
}
}