I am getting the following error while observe data from firebase realtime database. What I want to do is if the error is Permission Denied, I want to do a different action. How can I tell if the error is Permission Denied?
error :
Optional(Error Domain=com.firebase Code=1 "Permission Denied" UserInfo={NSLocalizedDescription=Permission Denied})
mycode:
func observeData(completion: @escaping (Bool) -> Void){
Database.database().reference().child("values").observe(.value, with: { (snap) in
completion(true)
}){ (error) in
let errorCode = (error as NSError).code
if errorCode == .?????? { //-->> what to come here
self.anotherFunc() //--> if Permission Denied call this func
completion(false)
}else{
completion(true)
}
}
}