Error saving user data to firebase in swift

Viewed 89

In my project i am saving user data to Firebase. i am getting user data from server after that i am saving this data to firebase. At a time i am trying to save 300 user data to firebase at a time. When i am running the loop all the user email are registered to firebase successfully.But when i am trying to save user data in firestore all the user data is not stored to firestore. some user data are missing. My code is-

 class func registerUserWith(email: String, password: String, firstName: String, lastName: String, avatar: String, phoneNumber: String, country: String, gender: String, userType: String, state: String, city: String, registerUseId: String, completion: @escaping (_ error: Error?) -> Void ) {
        
        Auth.auth().createUser(withEmail: email, password: password, completion: { (firuser, error) in
            
            if error != nil {
                
                completion(error)
                return
            }
 
            
            let fUser = FUser(_objectId: firuser!.user.uid, _pushId: "", _createdAt: Date(), _updatedAt: Date(), _email: firuser!.user.email!, _firstname: firstName, _lastname: lastName, _avatar: avatar, _loginMethod: kEMAIL, _phoneNumber: phoneNumber, _city: city, _state: state, _country: country, _registerUseId: registerUseId, _gender: gender, _userType: userType )
            
            saveUserLocally(fUser: fUser)
            saveUserToFirestore(fUser: fUser)
            completion(error)
            
        })
        
    }

Following code is for saving user data to firebase

//MARK: Save user funcs

func saveUserToFirestore(fUser: FUser) {
    reference(.User).document(fUser.objectId).setData(userDictionaryFrom(user: fUser) as! [String : Any]) { (error) in
        
        print("error is \(error?.localizedDescription)")
    }
}


func saveUserLocally(fUser: FUser) {
    
    UserDefaults.standard.set(userDictionaryFrom(user: fUser), forKey: kCURRENTUSER)
    UserDefaults.standard.synchronize()
}

Please let me know where i am doing the wrong.

1 Answers

In the Authentication section click on sign-in method. then in the bottom there is a option Manage sign-up quota. change the Current quota per hour . make it 1000. it may help you.

Related