Google在Android上的超级缓慢签名
我目前正在测试我的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试指定特定范围。
但首先:
googleapis
依赖项添加到 pubspec我正在使用范围组合:
还有这些导入:
希望这会有所帮助!
Try to specify particular scope.
But first:
googleapis
dependency to pubspecI was playing around with the scopes combination:
And also these imports:
Hope this helps!