Google在Android上的超级缓慢签名

发布于 2025-01-21 02:47:43 字数 1230 浏览 3 评论 0原文

我目前正在测试我的Android设备上的Flutter应用程序。我已经使用Firebase添加了与Google的签名。在iOS上,一切都很好,而且Android仿真器也效果很好。

但是,在我的物理三星设备上,情况并不那么光滑。

当您按下Google登录按钮时,我会有这个:

import 'package:firebase_auth/firebase_auth.dart';
import 'package:google_sign_in/google_sign_in.dart';

Future<User?> signInWithGoogle() async {
  // Trigger the authentication flow
  final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();

  // Obtain the auth details from the request
  final GoogleSignInAuthentication? googleAuth =
      await googleUser?.authentication;

  // Create a new credential
  final credential = GoogleAuthProvider.credential(. <--- This takes forever
    accessToken: googleAuth?.accessToken,
    idToken: googleAuth?.idToken,
  );

  // Once signed in, return the UserCredential
  final authResult =
      await FirebaseAuth.instance.signInWithCredential(credential);
  return authResult.user;
}

创建凭据变量,它需要永远(分钟)。稍后,在管道中,我正在加载Firebase数据库中的数据。

只需此行

final snapshot =等待firebaseadabase.instance.ref()。子(userkey).get();

需要分钟才能完成。我以前从未经历过。在我的设备上冲浪,wifi效果很好。

我尽可能地更新了我的Android设备,然后按预期工作。它可以在较旧的Android版本上使用吗?似乎此功能几乎所有应用程序都在使用并且应该起作用?

I am currently testing my Flutter app on my Android Device. I have added sign in with Google using Firebase. On iOS everything works just fine, and also Android Emulators works good.

On my physical Samsung Device however, things are not as smooth.

I have this when you press the Google Sign In Button:

import 'package:firebase_auth/firebase_auth.dart';
import 'package:google_sign_in/google_sign_in.dart';

Future<User?> signInWithGoogle() async {
  // Trigger the authentication flow
  final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();

  // Obtain the auth details from the request
  final GoogleSignInAuthentication? googleAuth =
      await googleUser?.authentication;

  // Create a new credential
  final credential = GoogleAuthProvider.credential(. <--- This takes forever
    accessToken: googleAuth?.accessToken,
    idToken: googleAuth?.idToken,
  );

  // Once signed in, return the UserCredential
  final authResult =
      await FirebaseAuth.instance.signInWithCredential(credential);
  return authResult.user;
}

Creating the credential variable it takes forever (minutes). Later in the pipeline, I am loading data from my Firebase database.

Just this line

final snapshot = await FirebaseDatabase.instance.ref().child(usersKey).get();

takes minutes to complete. I have never experienced this before. Surfing on my device and the WIFI works just fine.

I updated my Android device as much as possible and then it worked as expected. Can it be that it does not work on older Android Versions? Seems like this feature is something that almost all apps are using and should work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里寻她 2025-01-28 02:47:43

尝试指定特定范围。

但首先:

  • 需要有 OAuth 同意屏幕(至少)所有非限制范围
  • googleapis 依赖项添加到 pubspec

我正在使用范围组合:

GoogleSignInAccount? googleUser = await GoogleSignIn(
      scopes: [
        // people.PeopleServiceApi.userEmailsReadScope,
        people.PeopleServiceApi.userinfoEmailScope,
        // firebase.FirebaseDynamicLinksApi.firebaseScope
      ]).signIn();

还有这些导入:

import 'package:googleapis/people/v1.dart' as people;
import 'package:googleapis/firebasedynamiclinks/v1.dart' as firebase;

希望这会有所帮助!

Try to specify particular scope.

But first:

  • One needs to have OAuth Consent Screen with (at least) all non-restricted scopes
  • add googleapis dependency to pubspec

I was playing around with the scopes combination:

GoogleSignInAccount? googleUser = await GoogleSignIn(
      scopes: [
        // people.PeopleServiceApi.userEmailsReadScope,
        people.PeopleServiceApi.userinfoEmailScope,
        // firebase.FirebaseDynamicLinksApi.firebaseScope
      ]).signIn();

And also these imports:

import 'package:googleapis/people/v1.dart' as people;
import 'package:googleapis/firebasedynamiclinks/v1.dart' as firebase;

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文