0

I am just getting started working with Firebase, so I connected a test login/reg app (named RealLogin) to a database and everything was looking great, super easy, worked great.

Now I am incorporating this into another application, but when i try and set the referenceFromURL, it still tells me it is expecting the RealLogin database URL. I have since deleted the RealLogin xCode files and all Firebase connections, but its still wants that original database url..

Here is my code:

@IBAction func registerButtonPressed(_ sender: UIButton) {

    FIRAuth.auth()?.createUser(withEmail: emailTextField.text!, password: passwordTextField.text!, completion: { (user, error) in
        if error != nil {
            print(error!)
        }

        let ref = FIRDatabase.database().reference(fromURL: "https://intentiontracker.firebaseio.com")
        let userReference = ref.child("users")
        let values = ["name": self.nameTextField.text, "email": self.emailTextField.text]

        userReference.updateChildValues(values, withCompletionBlock: { (err, ref) in
            if err != nil {
                print(err!)
            }
        })
    })

}

And here is the error I am getting upon clicking the Register button:

Terminating app due to uncaught exception 'InvalidDatabaseURL', reason: 'Invalid URL (https://intentiontracker.firebaseio.com) passed to getReference(). URL was expected to match configured Database URL: https://reallogin-d047d.firebaseio.com'
Dan
  • 792
  • 1
  • 7
  • 17
  • 1
    This is a little odd in that your FIRDatabase is configured via FIRApp.configure() in your AppDelegate (generally). Check your GoogleService-Info file - the DATABASE_URL key as that's what Firebase will (should) use to connect to the url. Oh, and you can add your new App to your Firebase database in the console and generate a new info file as well. – Jay Jan 06 '17 at 18:14
  • Hello There! Please mark the answer as correct since it solved your issue. – Mago Nicolas Palacios Jan 09 '17 at 20:07

1 Answers1

0

It all comes to GoogleService-Info File thats added to your project and your package name. You should have a Firebase Project configured with your package name, Download the GoogleService-Info File and added it to your project. Then you should be ok and it should work.

Mago Nicolas Palacios
  • 2,501
  • 1
  • 15
  • 27