1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Firebase+swift】学習記録(3)登録・ログイン機能を作る

Posted at

Firebaseを使って簡単にユーザー登録とログイン機能が作れました。
今回はサインアップ画面を作ってみよう(Firebase)
を参考にして、ユーザー登録とログイン機能を兼ね備えたアプリを作成しました。

GitHubはこちら

ユーザー登録について

signup.swift
@IBAction func signupTapped(_ sender: Any) {
        //AuthのcreateUserでユーザー登録保存
        Auth.auth().createUser(withEmail: email.text!, password: password.text!) { (user, error) in
            if error != nil {
                print("登録できませんでした")
            }
                
            else {
                print("登録できました")
        }
    }

ログインについて

login.swift
@IBAction func loginTapped(_ sender: Any) {
        //ログイン用はsignIn
        Auth.auth().signIn(withEmail: email.text!, password: password.text!) { (user, error) in
            if error != nil {
                print("ログインできませんでした") 
            }
            else {
                print("ログインできました")
            }
        }
    }

画面遷移を付け加えれば、これだけでユーザー登録とログイン機能が作れます。
わーい

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?