栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何处理Flubase上的Firebase Auth异常

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何处理Flubase上的Firebase Auth异常

(21/02/20)编辑:这个答案很旧,其他答案包含跨平台解决方案,因此您应该首先看看他们的解决方案,并将其视为后备解决方案。

firebase auth插件实际上还没有合适的跨平台错误代码系统,因此您必须独立处理android和ios的错误。

我当前正在使用此github问题的临时修复程序:#20223

请注意,因为它是 临时 修复程序,所以不要指望它作为永久解决方案是完全可靠的。

enum authProblems { UserNotFound, PasswordNotValid, NetworkError }try {  FirebaseUser user = await FirebaseAuth.instance.signInWithEmailAndPassword(      email: email,      password: password,  );} catch (e) {  authProblems errorType;  if (Platform.isAndroid) {    switch (e.message) {      case 'There is no user record corresponding to this identifier. The user may have been deleted.':        errorType = authProblems.UserNotFound;        break;      case 'The password is invalid or the user does not have a password.':        errorType = authProblems.PasswordNotValid;        break;      case 'A network error (such as timeout, interrupted connection or unreachable host) has occurred.':        errorType = authProblems.NetworkError;        break;      // ...      default:        print('Case ${e.message} is not yet implemented');    }  } else if (Platform.isIOS) {    switch (e.pre) {      case 'Error 17011':        errorType = authProblems.UserNotFound;        break;      case 'Error 17009':        errorType = authProblems.PasswordNotValid;        break;      case 'Error 17020':        errorType = authProblems.NetworkError;        break;      // ...      default:        print('Case ${e.message} is not yet implemented');    }  }  print('The error is $errorType');}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/427716.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号