LoginSignup
2
1

はじめに

Firebase Authenticationでユーザがログインした際、初回登録時のみFirestoreにユーザ情報を追加するという処理を実現したいと考えました。
そこで、ログインしたユーザが新規登録かどうか判定する必要がありました。

コード

let authResult = try await Auth.auth().signInAnonymously()
print(authResult.additionalUserInfo?.isNewUser)

AdditionalUserInfoisNewUserで初回ログインかどうか判定することができます。
エラー処理などは省いています。

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