- Today
- Total
Act99 기술블로그
[비전공자] Flutter + Firebase | google_sign_in issue: PlatformException(sign_in_required, com.google.android.gms.common.api.ApiException: 4: 4: , null)) 에러가 날 경우 본문
[비전공자] Flutter + Firebase | google_sign_in issue: PlatformException(sign_in_required, com.google.android.gms.common.api.ApiException: 4: 4: , null)) 에러가 날 경우
Act99 2020. 11. 19. 20:56Flutter와 Firebase Auth 를 연동시키다보면 가끔
google_sign_in issue: PlatformException(sign_in_required, com.google.android.gms.common.api.ApiException: 4: 4: , null))
에러가 뜬다. 가령,
필자의 경우
@override
void initState() {
super.initState();
// Detects when user signed in
googleSignIn.onCurrentUserChanged.listen((account) {
handleSignIn(account);
}, onError: (err) {
print('Error signing in: $err');
});
googleSignIn.signInSilently(suppressErrors: false).then((account) {
handleSignIn(account);
}).catchError((err) {
print('Error signing in: $err');
});
}
여기서 googleSignIn.signInSilently() 쪽에서 에러가 생겼다.
- 해결방법 -
--------------------------------- 이 코드를
googleSignIn.signInSilently(suppressErrors: false).then((account) {
handleSignIn(account);
}).catchError((err) {
print('Error signing in: $err');
});
---------------------------------
googleSignIn.isSignedIn().then((isSignedIn) async {
if (isSignedIn)
await {
googleSignIn.signInSilently().then((account) => handleSignIn(account))
};
});
이렇게 대체하면 된다. (async / await은 생략 가능)