ios - 在 Firebase 上注册新用户时出错

标签 ios swift firebase firebase-authentication

当我尝试注册新用户时,我收到一条错误消息,提示类型 'FIRDatabaseReference' 的值没有成员 'createuser'。见下图。

FIRAuth.auth()?.createUserWithEmail(<email: String>, password: <String>, completion: <FIRAuthResultCallback?(FIRUser?, NSError?) -> Void#>)

下面是代码和 ImageView 的截图:

enter image description here

最佳答案

试试这段代码,它对我来说绝对没问题

//
//  ViewController.swift
//  FirebaseExample
//
//  Created by Belal Khan on 03/10/16.
//  Copyright © 2016 Belal Khan. All rights reserved.
//

import UIKit

//importing firebase
import Firebase

class ViewController: UIViewController {

    //Textfields for email and password
    @IBOutlet weak var textFieldEmail: UITextField!
    @IBOutlet weak var textFieldPassword: UITextField!

    //label for displaying message
    @IBOutlet weak var labelMessage: UILabel!

    //button for registration
    @IBAction func buttonRegister(sender: UIButton) {
        //do the registration operation here

        //first take the email and password from the views
        let email = textFieldEmail.text
        let password = textFieldPassword.text

        FIRAuth.auth()?.createUserWithEmail(email!, password: password!, completion: { (user: FIRUser?, error) in
            if error == nil {
                self.labelMessage.text = "You are successfully registered"
            }else{
                self.labelMessage.text = "Registration Failed.. Please Try Again"
            }

        })
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        //initialising firebase
        FIRApp.configure()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

来源:swift firebase tutorial

关于ios - 在 Firebase 上注册新用户时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38165855/

相关文章:

ios - UIAlertController 的外观

ios - Swift 3 numberOfRows TableView 函数错误

ios - 为什么 NSMutableData 改变指针的地址?

ios - 如何在 swift 中使用 NSUserDefaults 保存字符串数组

java - Android 的 Firestore 超时

ios - 快速解码 httpsCallable 云函数响应

firebase - Firestore : Updating field in an object removes previous field

ios - 拆除 UITableViewDataSource

ios - 如何创建一个里面有 2 个数组的字典?

ios - 错误 UIViewController 没有成员