I'm having a nifty bug where I get this error: "Firestore: The caller does not have permission to execute the specified operation. (firestore/permission-denied)."
in iOS only, but not in Android using identical versions of the codebase. In fact, I have both iOS and Android emulators going to the same node server and I'm going back and forth between them and setting breakpoints to see where it's happening. I don't have any native code that would make the difference other than the config stuff required to set up the packges I have installed for the project. Here's a snippet of the query:
let query = momentsRef.where('uid', '==', uid)
query.get().then((snapshot) => { /*etc*/ }).catch((e) => /*fails here on iOS with the error above*/)
The security rules in Firestore for momentsRef (which points to 'user_activity') are:
match /user_activity/{activityId} {
allow write: if request.auth.uid != null;
allow read: if request.auth.uid != null;
}
This code is called after the user has successfully logged in with the same method on both iOS and Android. I have also double checked that uid
is defined on iOS when the where
query is generated.
Only on iOS, not on Android. Tested using an iPhone 6 emulator on iOS 11.2 and a Nexus 5X emulator on Nougat.
Application Target Platform: ?
Development Operating System: This was built and tested on macOS 10.13.2 using node v9.3.0
Build Tools: Android build tools
React Native version: "react-native": "0.51.0"
RNFirebase Version: "react-native-firebase": "3.2.2"
The gradle configuration. Note that we add com.google.android.gms
elsewhere and exclude it here so that the same version is used across the app.
implementation(project(':react-native-firebase')) {
transitive = false
exclude group: "com.google.android.gms"
}
compile "com.google.firebase:firebase-core:11.8.0"
compile "com.google.firebase:firebase-auth:11.8.0"
compile "com.google.firebase:firebase-analytics:11.8.0"
compile "com.google.firebase:firebase-firestore:11.8.0"
The pod configuration for iOS:
pod 'RNFirebase', :path => '../node_modules/react-native-firebase/iOS'
pod 'Firebase/Analytics'
pod 'Firebase/Auth' , '~> 4.8.1'
pod 'Firebase/Firestore'
What鈥檚 the reasoning for fixing the version of Auth to 4.8.1?
This version was actually dropped from release by Firebase due to issues - I鈥檇 suggest removing the version restriction, updating your pods and seeing whether this is the cause of the problem.
Nice! One of our developers had added that to try to fix a different bug, but it seems that it was not needed. I removed that line, ran pod install
, and then deleted the app from the emulator. I also deleted and cleaned the npm cache. Then after running react-native run-ios
again, it seems to be working perfectly. Thanks!
Awesome, glad it's resolved!
Most helpful comment
Nice! One of our developers had added that to try to fix a different bug, but it seems that it was not needed. I removed that line, ran
pod install
, and then deleted the app from the emulator. I also deleted and cleaned the npm cache. Then after runningreact-native run-ios
again, it seems to be working perfectly. Thanks!