我有以下数据库规则:
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
}
在iOS端:
FIRAuth.auth()?.signInWithCustomToken(token, completion: { (user, error) in
if error == nil {
let userRef = FIRDatabase.database().reference().child("users").child(user!.uid)
userRef.observeSingleEventOfType(.Value, withBlock: { (snap) in
//....
printD("working...")
}, withCancelBlock: { (error) in
printD(error)
})
}
})
}
控制台输出:
[Error Domain=com.firebase Code=1 "Permission Denied" UserInfo={NSLocalizedDescription=Permission Denied}]
打印用户!.uid给出"ODEzYjIzNzctMTFmMC00NjhhLWIxNTAtZjExN2I0MXXXXXX1"