简体   繁体   English

如何在一个扑动的应用程序中使用firebase phone auth

[英]How to do firebase phone auth in a flutter app

I've done all the steps to attach my database and proven I can get data that isn't protected by any auth rules. 我已经完成了附加数据库的所有步骤,并证明我可以获得不受任何身份验证规则保护的数据。 Now I want to implement phone sign in and add auth rules. 现在我想实现手机登录并添加身份验证规则。

flutter doctor and flutter analyze both return no errors. flutter doctorflutter analyze都没有返回任何错误。 I've copied the example code from here, the firebase_auth plugin example code 我从这里复制了示例代码,firebase_auth插件示例代码

The important point is here: 重要的是这里:

await _auth.verifyPhoneNumber(
    phoneNumber: _phoneNumberController.text,
    timeout: const Duration(seconds: 5),
    verificationCompleted: verificationCompleted,
    verificationFailed: verificationFailed,
    codeSent: codeSent,
    codeAutoRetrievalTimeout: codeAutoRetrievalTimeout);
}

When I run this line (iPhone simulator from VS code), I get no message on the console, the debug session ends, the simulator screen goes black, and seconds later returns to the home screen. 当我运行此行(来自VS代码的iPhone模拟器)时,我在控制台上没有消息,调试会话结束,模拟器屏幕变黑,几秒钟后返回主屏幕。

I'm new to all of this, but the only idea I have is this: when I print on the console _auth.verifyPhoneNumber , I get this 我是所有这一切的新手,但我唯一的想法就是:当我在控制台_auth.verifyPhoneNumber上打印时,我得到了这个

Closure: ({String phoneNumber, Duration timeout, int forceResendingToken, (AuthCredential) => void verificationCompleted, (AuthException) => void verificationFailed, (String, [int]) => void codeSent, (String) => void codeAutoRetrievalTimeout}) => Future from Function 'verifyPhoneNumber':. 闭包:({String phoneNumber,Duration timeout,int forceResendingToken,(AuthCredential)=> void verificationCompleted,(AuthException)=> void verificationFailed,(String,[int])=> void codeSent,(String)=> void codeAutoRetrievalTimeout}) =>函数'verifyPhoneNumber'的未来:

Notice that the third parameter is int forceResendingToken , which is not in my code. 请注意,第三个参数是int forceResendingToken ,它不在我的代码中。 I can't find any doc about this. 我找不到任何关于此的文档。

Two questions: 1. Can you help me get auth working, and 2. Can you help me navigate docs on my own? 两个问题:1。你能帮我认证吗?2。你能帮助我自己导航文档吗? In flutter, I don't know which firebase docs to look at. 在颤动中,我不知道要查看哪个firebase文档。 Can you show me the link, for example, for the auth methods that should be used in flutter? 你能告诉我链接,例如,应该在flutter中使用的auth方法吗?

Thanks! 谢谢!

Well, it turns out that a simple URL scheme with just an array inside the item dictionary isn't the right format for firebase. 好吧,事实证明,在项目字典中只有一个数组的简单URL方案不是firebase的正确格式。 It must look like this: 它必须如下所示:

在此输入图像描述

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

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