Firebase Database setValue: or removeValue failed: permission_denied iOS
I had a similar issue. It was resolved by resetting the read / write rules for the database. If you changed your rules try reseting them to the default.
Warning: These rules allow anyone to read and write to your database!
Default Rules for Real-time Database
{
"rules": {
".read": true,
".write": true
}
}
Default Rules for Cloud Firestore
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
FreddieOh and I chatted over Slack, and the problem was that the database that was listed in the GoogleService-info.plist
file didn't match up with the one he was editing. (It looks like maybe in this case, he had deleted and recreated the project in the Firebase console, but hadn't updated the plist file.)
If you find yourself in the same situation where you've set your read and write access to true and are still getting permission denied errors, open up your GoogleService-info.plist
file and look at the entry for DATABASE_URL
. Then go to the Firebase Database in your project, look at the top of the data tab, and confirm that the URL listed there is the same as the one in your plist file.
I suppose the other thing to check for would be that you updated your database rules to allow global access but forgot to click the Publish button. That... may have happened to me at one point. :)
Go to your Firebase console, and perform following steps which is identify in image.
Please lookup image and follow these steps. If you are beginner and facing problem in image. I make little video about error.
Video Solution : https://youtu.be/FcQCPqckvqo
Image Solution