I have a react-native app which figures out if a user allows Firebase Cloud Messaging and then saves the users Token. It also saves the users GeoLocation around this same time.
These functions both work fine if debug mode is enabled on my emulator. However, if debug mode is not running I receive a permission denied warning. Does anyone know why this only works in debug mode?
geoFire.set(uid, [userLocation.lat, userLocation.lng]);
Above code should save the location. (This works with debug mode enabled).
const firebaseConfig = {
apiKey: 'AIzaSyAZxxxxxxx',
authDomain: 'thxxxxxx',
databaseURL: 'https://thxxxxxxx',
storageBucket: 'thxxxxxxxxxxxxx',
}
// Initialize Firebase
const Firebase = firebase.initializeApp(firebaseConfig)
I use realtime database with the following access rules
{
"rules": {
".read": "auth.uid != null",
".write": "auth.uid != null"
}
}
I found that a lot of users got this warning message/problem because the rights of the database are not correct. However I double-checked these with the Firebase manual and they should work like this (tested in the Rules Playground in the firebase console.
Permission denied error means that security rules rejected the query. If the only rules for your app are what's shown here, it means that there is no user signed in to the app at the time of the query.