0
1

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 3 years have passed since last update.

Firebase/Authenticationで匿名ログインにする方法

Posted at

##Friebaseで匿名ログイン
よくメールアドレス認証などは見られますが、匿名ログインについてはあまり見られないように思いますので、自身の備忘録を含めて記事を書こうと思います。

以下のコードを例えばIBActionのなかに書くことで匿名ログインが可能になります。

Auth.auth().signInAnonymously() { ( authResult, err ) in
            if let err = err {
                print("エラー\(err)")
                return
            }
            
            guard let user = authResult?.user else { return }
            let isAnonymous = user.isAnonymous
            self.uid = user.uid
            print("サインインに成功しました。\(self.uid)")
        }

ちなみにemail認証の時はAuth.auth().createUser()です。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?