简体   繁体   English

我在 flutter 中遇到 firebase 身份验证问题

[英]i have a problem with firebase auth in flutter

i have this error when i run my app on debug mode i want to print auth token but when i reload the app i received this message D当我在调试模式下运行我的应用程序时出现此错误我想打印授权令牌但是当我重新加载应用程序时我收到此消息 D

> /ViewRootImpl@22a08dc\[MainActivity\]( 6846): Relayout returned: old=(0,0,720,1480) new=(0,0,720,1480) req=(720,1480)0 dur=14 res=0x3 s={true 4058093568} ch=false
> E/flutter ( 6846): \[ERROR:flutter/runtime/dart_vm_initializer.cc(41)\] Unhandled Exception: \[firebase_messaging/unknown\] java.io.IOException: FIS_AUTH_ERROR
> E/flutter ( 6846): #0      StandardMethodCodec.decodeEnvelope
> package:flutter/…/services/message_codecs.dart:653
> E/flutter ( 6846): #1      MethodChannel.\_invokeMethod
> package:flutter/…/services/platform_channel.dart:296
> E/flutter ( 6846): \<asynchronous suspension\>
> E/flutter ( 6846): #2      MethodChannel.invokeMapMethod
> package:flutter/…/services/platform_channel.dart:499
> E/flutter ( 6846): \<asynchronous suspension\>
> E/flutter ( 6846): #3      MethodChannelFirebaseMessaging.getToken
> package:firebase_messaging_platform_interface/…/method_channel/method_channel_messaging.dart:224
> E/flutter ( 6846): \<asynchronous suspension\>
> E/flutter ( 6846):

i tried to delete build folder and rebuild it and it's not works我试图删除构建文件夹并重建它但它不起作用

Make sure you have installed the latest firebase_auth and firebase_core packages.确保您已安装最新的 firebase_auth 和 firebase_core 软件包。 If the issue still persists, check whether you have integrated firebase properly.如果问题依然存在,请检查您是否正确集成了firebase。 Delete the firebase_options.dart file (android) and try to integrate your firebase project with your flutter application again删除 firebase_options.dart 文件 (android) 并再次尝试将您的 firebase 项目与您的 flutter 应用程序集成

If I guessed well, the problem is that when you reaload, the token is not available yet, because the session is loading or something like.如果我猜对了,问题是当你重新加载时,令牌还不可用,因为 session 正在加载或类似的东西。

and I think you are getting your token like this final token = objectWithToken.token and this causes the error because token is undefined so you should make a condition我认为你得到的是像这样的final token = objectWithToken.token的令牌,这会导致错误,因为令牌undefined ,所以你应该设定一个条件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM