Swift Storing Information for each Firebase User

So I've implemented Firebase into my application, so the user can now make an account and login.

@IBAction func signIn(sender: UIButton) {     FIRAuth.auth()?.signInWithEmail(username.text!, password: password.text!, completion: {         user, error in          if error != nil{             print("Didn't work")         }         else{             print("Worked")         self.performSegueWithIdentifier("signinSegue", sender: sender)         }     }) } 

I also have NSUserDefaults set up to save information. But with NSUserDefaults, I have only been able to save info based on phone, not based off of user. So if someone logs into the same account from a different phone, his information won't be there (his information is in his old phone).

let defaults = NSUserDefaults.standardUserDefaults()  func loadUserDefaults() {      if let tempEntries = defaults.objectForKey("keySave") as? NSData {         let decodedEntries: NSArray = NSKeyedUnarchiver.unarchiveObjectWithData(tempEntries) as! [Entry!]         print(decodedEntries)         entries = decodedEntries as! [Entry]     } }  override func viewDidLoad() {      super.viewDidLoad()       loadUserDefaults() } 

How do I load information based on a specific user in Firebase?

Replay

I would use the Firebase Realtime Database to store user-related information. This database will sync in real-time across all devices. A helpful tutorial can be found here:

https://firebase.google.com/docs/database/ios/save-data

The database is stored in the JSON format.

Category: swift Time: 2016-07-29 Views: 5

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.145 (s). 12 q(s)