React-native-firebase: Firestore: Caller does not have permission to execute on iOS but not Android with same codebase

Created on 20 Feb 2018  路  3Comments  路  Source: invertase/react-native-firebase

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.

Environment

Only on iOS, not on Android. Tested using an iPhone 6 emulator on iOS 11.2 and a Nexus 5X emulator on Nougat.

  1. Application Target Platform: ?

  2. Development Operating System: This was built and tested on macOS 10.13.2 using node v9.3.0

  3. Build Tools: Android build tools

  4. React Native version: "react-native": "0.51.0"

  5. 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'
  1. Firebase Module: Firestore
Waiting for User Response

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 running react-native run-ios again, it seems to be working perfectly. Thanks!

All 3 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mahyarr picture mahyarr  路  3Comments

Damnum picture Damnum  路  3Comments

csumrell picture csumrell  路  3Comments

dgruseck picture dgruseck  路  3Comments

jonaseck2 picture jonaseck2  路  3Comments