Fre*_*nga 5 safari google-signin flutter googlesigninaccount flutter-web
PlatformException(popup_blocked_by_browser, Exception raised from GoogleAuth.signIn()当我尝试使用 google_sign_in flutter 包通过 Google 登录时,我不断地进行
每一次尝试。只有当我使用 Safari 时才会出现这种情况,在 chrome 上没问题。我想知道为什么它在第一次尝试时失败,但在之后的尝试中有效。如果我刷新浏览器,第一次尝试就会再次失败。
这是我使用 firebase auth 和 google 登录的功能
@override
Future<auth.User?> signInWithGoogle() async {
final GoogleSignInAccount? googleUser =
await _googleSignIn.signInSilently();
final GoogleSignInAuthentication? googleAuth =
await googleUser?.authentication;
if (googleAuth == null) {
return null;
}
final AuthCredential credential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
final UserCredential userCredential =
await _firebaseAuth.signInWithCredential(credential);
return auth.User(
uid: userCredential.user?.uid,
email: userCredential.user?.email,
);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
223 次 |
| 最近记录: |