• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    미해결

[개선코드]signinAndSignup()의 else문 보완

21.04.09 16:10 작성 조회수 80

2

fun signinAndSignup() {
        auth?.createUserWithEmailAndPassword(email_edittext.text.toString(), password_edittext.text.toString())
            ?.addOnCompleteListener {
            task ->
                if (task.isSuccessful) {    //계정 만들기에 성공했을 때
                    //Creating a user account
                    moveMainPage(task.result?.user)
                } else {
                    //Login if you have account
                    if (task.exception?.message.equals("The email address is already in use by another account."))
                        signinEmail()
                    //Show the error message
                    else Toast.makeText(this, task.exception?.message, Toast.LENGTH_LONG).show()
                }
            }
    }

 동일 계정 존재로 인한 exception일 경우 signinEmail() 함수를 호출하도록 했습니다. (그 외 이메일 형식 오류 또는 비밀번호 형식 오류일 경우 Toast로 에러 메시지를 보여줍니다.)

답변 0

답변을 작성해보세요.

답변을 기다리고 있는 질문이에요.
첫번째 답변을 남겨보세요!