菜鸟教程小白 发表于 2022-12-11 19:07:18

ios - Firebase 数据库不工作


                                            <p><p>我正在开发一个需要 Firebase 身份验证和数据库的应用。注册时,应用程序必须检查输入的代码是否真实,然后继续创建用户。这是我的代码:</p>

<pre><code>ref = FIRDatabase.database().reference()

    self.ref.child(&#34;PatientCodes&#34;).observeSingleEvent(of: .value, with: { (snaphshot) in
      print(&#34;In&#34;)
      let value = snaphshot.value as! NSArray

      if value.contains(self.patientIDTextField.text!) {
            print(&#34;Found ID&#34;)

            FIRAuth.auth()?.createUser(withEmail: self.emailTextField.text!, password: self.passwordTextField.text!, completion: { (user, error) in
                if user != nil {
                  self.performSegue(withIdentifier: &#34;registered&#34;, sender: self)
                }
            })

      }
</code></pre>

<p>我遇到的问题是,没有代码在 <code>self.ref.child</code> 等之后执行。 <code>print("In")</code> 语句永远不会被命中.</p>

<p>非常感谢任何帮助。提前致谢。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>在开始使用 <code>Firebase 数据库</code> 之前,
首先检查控制台中数据库下的规则是否设置正确,即读取是 <code>true</code> 还是写入是 <code>true</code>。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - Firebase 数据库不工作,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/42522084/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/42522084/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - Firebase 数据库不工作