0
votes

Her is my database/rules:

{
  "rules": {
    ".read": true,
    ".write": true
  }
}

i am trying both way it is give me nil

 FIRAuth.auth()?.createUser(withEmail: email, password: pass, completion: { (firuser, error) in
      
     if error != nil {
    print("error goes when try to user authenticated :) \(error)")
  }
  
  print("firuser : \(firuser)")

  print("FIRAuth.auth()?.currentUser?.uid : \(FIRAuth.auth()?.currentUser?.uid)")
  
  print("firuser?.uid : \(firuser?.uid)")
  
  guard let userUID = firuser?.uid  else{
     print("user UID  not found. should go stackoverflow ")
  return
  }
      
      guard let userUID = firuser?.uid  else{
         print("user UID  not found. should go stackoverflow ")
      return
      }
})

console log :

error :

Optional(Error Domain=FIRAuthErrorDomain Code=17995 "An error occurred when accessing the keychain. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain more information about the error encountered" UserInfo={NSLocalizedDescription=An error occurred when accessing the keychain. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain more information about the error encountered, error_name=ERROR_KEYCHAIN_ERROR, NSLocalizedFailureReason=SecItemAdd (-34018)})

firuser : nil
FIRAuth.auth()?.currentUser?.uid : nil
firuser?.uid : nil

server user added :

enter image description here

1
What gives you nil? The firuser? The error? Is there an error? Is email and pass valid? Please don't use 'return' in Firebase closures as they are not needed and errors should be handled more elegantly. Please update and clarify the question so we can help. - Jay
@Jay i updated my question . could you check that please . if your need any information let me know please - cristan lika

1 Answers

4
votes

i was faced same problem ..but solve this way

Go to your *.xcodeproj

Go to the tab "Capabilities"

Activate "Keychain Sharing"