본문 바로가기

카테고리 없음

[에러 디버깅] react-native 안드로이드 환경 firebase auth().signInWithEmailAndPassword메서드 에러: Given String is empty or null

firebase를 통해 로그인 기능을 구현하고 있었는데 안드로이드와 ios환경에서 값을 처리하는 방식이 달랐다.

firebase에서 이메일인증방식으로 로그인을 구현하기 위해 제공하는 메서드는 signInWithEmailAndPassword 함수인데 안드로이드 환경에서는 이메일과 패스워드를 빈값으로 보냈을 때 시스템자체에서 "Given String is empty or null"라는 문구와 함께 에러가 발생하고, ios환경에서는 api의 응답값으로 에러메시지를 던져줬다.

 

안드로이드 환경에러

 

관련된 내용으로 깃헙 이슈가 등록되어있었는데

https://github.com/invertase/react-native-firebase/issues/127

 

Crash when trying signInWithEmailAndPassword with empty string · Issue #127 · invertase/react-native-firebase

In Firebase Web SDK, it provides error response instead of an exception. (We encountered this error after migrating from Web SDK to this react-native-firebase.) I think it is better it works same a...

github.com

firebase auth 측 답변으로는 react-native자체에서 에러를 처리해야 한다고 하고 마무리가 되었다. 결국엔 프런트에서 함수를 호출하기 전 다음과 같이 유효성검사를 하는 방법 외엔 막는 방법이 없음으로 결론지었다. 같은 라이브러리라도 플랫폼 간에 처리하는 방식이 다를 수 있음을 알게 되었다.

 if (!form.email || !form.password) {
      setFormError('모든값을 입력해주세요.');

      return;
    }