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

FirebaseAuthを使ってログイン 〜ゼロからの KMP × Firebase〜

Posted at

前回からの続きです。

前回はSwiftUIでログイン画面を作成しました。

今回はFirebaseAuthを使って実際にログイン処理を実装します。

FirebaseAuthRepository作成

FirebaseAuthRepository.kt

import dev.gitlive.firebase.auth.FirebaseUser

interface FirebaseAuthRepository {
    suspend fun signIn(email: String, password: String)
}
FirebaseAuthRepositoryImpl.kt

import com.example.suzuapplication.repository.FirebaseAuthRepository
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.auth.auth

class FirebaseAuthRepositoryImpl : FirebaseAuthRepository {
    override suspend fun signIn(email: String, password: String) {
        Firebase.auth.signInWithEmailAndPassword(email, password)
    }
}

こちらがログインの処理になります。

これはRepository層の実装になります。
emailpasswordを設定するとログインすることができます。

このままこの処理を直接読んでもいいのですが、ViewModelを使用してみたいと思います。

次回予告

次回は、ViewModelを作成していきます。

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