0
1

More than 1 year has passed since last update.

【Swift】Firebaseで認証済みユーザーかどうか振り分ける処理

Last updated at Posted at 2021-03-01

最初の画面を認証済みユーザーと新規ユーザーとで切り替えたい時の処理

import UIKit
import Firebase
import FirebaseUI

class LaunchViewController : UIViewController{
        
    override func viewDidLoad() {
        super.viewDidLoad()
        //ロードされるまでの初期画面(ロゴ画像、ナビゲーションバーなど)
        }
    }
    override func viewDidAppear(_ animated: Bool) {
        
        if Auth.auth().currentUser != nil {
            self.performSegue(withIdentifier: "sign", sender: nil)
            print(認証済みユーザー)

        } else {
            self.performSegue(withIdentifier: "nosign", sender: nil)
            print(新規ユーザー)
        }
    }
}

ポイントはAuth.auth().currentUser != nilのif文

Swiftのお役立ち情報

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1