首页 > 解决方案 > PlatformException(popup_blocked_by_browser,从 GoogleAuth.signIn() 引发的异常

问题描述

PlatformException(popup_blocked_by_browser, Exception raised from GoogleAuth.signIn()尝试使用 google_sign_in 颤振包通过 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,
    );
  }

标签: fluttersafarigoogle-signinflutter-webgooglesigninaccount

解决方案


推荐阅读