gpt4 book ai didi

firebase - firebase_auth:禁用用户时,抛出PlatfromException而不是FirebaseAuthInvalidUserException?

转载 作者:行者123 更新时间:2023-12-03 03:57:15 25 4
gpt4 key购买 nike

FlutterSDK:1.12.13 + hotfix.7

这是我的简单代码:

final PhoneVerificationCompleted phoneVerificationCompleted =
(AuthCredential credential) async{
print("verified $phoneNumber");


try{
await FirebaseAuth.instance.signInWithCredential(credential);

} on PlatformException catch (exception){
print(exception);

} catch (error){

}

在我尝试从Firebase Console禁用帐户之前,它工作正常。
根据firebase的文档,FirebaseAuth应该抛出FirebaseAuthInvalidUserException
无论我仍然无法处理抛出的PlatFormException。
这就是当残疾人用户尝试登录时得到的信息。
[ +876 ms] E/flutter ( 2479): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception:
PlatformException(ERROR_USER_DISABLED, The user account has been disabled by an administrator., null)
[ +4 ms] E/flutter ( 2479): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
[ +29 ms] E/flutter ( 2479): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
[ +2 ms] E/flutter ( 2479):
[ +17 ms] E/flutter ( 2479): #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:349:48)
[ +4 ms] E/flutter ( 2479): #3 MethodChannelFirebaseAuth.signInWithCredential
(package:firebase_auth_platform_interface/src/method_channel_firebase_auth.dart:161:23)
[ +19 ms] E/flutter ( 2479): #4 FirebaseAuth.signInWithCredential (package:firebase_auth/src/firebase_auth.dart:208:10)
[ +2 ms] E/flutter ( 2479): #5 _RegisterUiState.verifyNumber.
(package:highest_price/ui/register_ui.dart:47:45)
[ +1 ms] E/flutter ( 2479): #6 MethodChannelFirebaseAuth._callHandler
(package:firebase_auth_platform_interface/src/method_channel_firebase_auth.dart:377:30)
[ +1 ms] E/flutter ( 2479): #7 MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:402:55)
[ ] E/flutter ( 2479): #8 MethodChannel.setMethodCallHandler.
(package:flutter/src/services/platform_channel.dart:370:54)
[ +1 ms] E/flutter ( 2479): #9 _DefaultBinaryMessenger.handlePlatformMessage
(package:flutter/src/services/binding.dart:200:33)
[ +3 ms] E/flutter ( 2479): #10 _invoke3. (dart:ui/hooks.dart:303:15)
[ +1 ms] E/flutter ( 2479): #11 _rootRun (dart:async/zone.dart:1126:13)
[ +19 ms] E/flutter ( 2479): #12 _CustomZone.run (dart:async/zone.dart:1023:19)
[ +1 ms] E/flutter ( 2479): #13 _CustomZone.runGuarded (dart:async/zone.dart:925:7)
[ ] E/flutter ( 2479): #14 _invoke3 (dart:ui/hooks.dart:302:10)
[ ] E/flutter ( 2479): #15 _dispatchPlatformMessage (dart:ui/hooks.dart:162:5)
[ ] E/flutter ( 2479):

最佳答案

尝试使用catchError,它将使您捕获异步代码错误:

final PhoneVerificationCompleted phoneCompleted =  (AuthCredential credential) {
FirebaseAuth.instance.signInWithCredential(credential).then((data){
print(data);
}).catchError((error){
print(error);
});
};

检查文档:

https://api.flutter.dev/flutter/package-async_async/DelegatingFuture/catchError.html

关于firebase - firebase_auth:禁用用户时,抛出PlatfromException而不是FirebaseAuthInvalidUserException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60053291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com