メールアドレスの認証が表示されません
謎です。
Swift
1import UIKit 2import Firebase 3import FirebaseUI 4 5@UIApplicationMain 6class AppDelegate: UIResponder, UIApplicationDelegate { 7 8 var window: UIWindow? 9 10 override init() { 11 super.init() 12 FirebaseApp.configure() 13 } 14 15 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 // Override point for customization after application launch. 17 // Use Firebase library to configure APIs 18// FirebaseApp.configure() 19 return true 20 } 21 22 // facebook&Google&電話番号認証時に呼ばれる関数 23 func application(_ app: UIApplication, open url: URL, 24 options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool { 25 let sourceApplication = options[UIApplication.OpenURLOptionsKey.sourceApplication] as! String? 26 // GoogleもしくはFacebook認証の場合、trueを返す 27 if FUIAuth.defaultAuthUI()?.handleOpen(url, sourceApplication: sourceApplication) ?? false { 28 return true 29 } 30 // other URL handling goes here. 31 return false 32 } 33 34 func applicationWillResignActive(_ application: UIApplication) { 35 // 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. 36 // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 37 } 38 39 func applicationDidEnterBackground(_ application: UIApplication) { 40 // 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. 41 // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 42 } 43 44 func applicationWillEnterForeground(_ application: UIApplication) { 45 // 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. 46 } 47 48 func applicationDidBecomeActive(_ application: UIApplication) { 49 // 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. 50 } 51 52 func applicationWillTerminate(_ application: UIApplication) { 53 // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 54 } 55 56 57}
Swift
1import UIKit 2import Firebase 3import FirebaseUI 4 5class RootTabBarController: UITabBarController, FUIAuthDelegate, UITabBarControllerDelegate { 6 7 var authUI = FUIAuth.defaultAuthUI()! 8 9 let providers: [FUIAuthProvider] = [ 10 FUIGoogleAuth(), 11 FUIPhoneAuth(authUI:FUIAuth.defaultAuthUI()!), 12 ] 13 14 override func viewDidLoad() { 15 super.viewDidLoad() 16 UITabBar.appearance().shadowImage = UIImage() 17 UITabBar.appearance().backgroundImage = UIImage() 18 19 self.delegate = self 20 21 // authUIのデリゲート 22 self.authUI.delegate = self 23 self.authUI.providers = providers 24 25 } 26 27 func checkLoggedIn() -> Bool { 28 var authCheck = false 29 Auth.auth().addStateDidChangeListener{auth, user in 30 if user != nil{ 31 //サインインしている 32 authCheck = true 33 } else { 34 //サインインしていない 35 self.login() 36 } 37 } 38 return authCheck 39 } 40 41 42 43 func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool { 44 print("ああああああ") 45 if viewController is HomeViewController { 46// return false 47 } else { 48 return checkLoggedIn() 49 } 50 return true 51 } 52 53 // 認証画面から離れたときに呼ばれる(キャンセルボタン押下含む) 54 public func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?){ 55 // 認証に成功した場合 56 if error == nil { 57 self.performSegue(withIdentifier: "toTopView", sender: self) 58 } 59 // エラー時の処理をここに書く 60 } 61 62 func login() { 63 // FirebaseUIのViewの取得 64 let authViewController = self.authUI.authViewController() 65 // FirebaseUIのViewの表示 66 self.present(authViewController, animated: true, completion: nil) 67 } 68 69} 70
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/20 01:31
2019/03/20 10:02
2019/03/20 10:14