React-native-firebase: [馃悰] firestore.onSnapshot ignoring firebase rules.

Created on 31 Aug 2020  路  8Comments  路  Source: invertase/react-native-firebase

Hello;

When i use .get() it works as it has to but when using onSnapshot im getting all the data and then the error firestore/permission-denied wich is useless since already got data.

Issue

firestore.collection('items').limit(15)
.orderBy('cdate', 'desc')
.get()

firestore.collection('items').limit(15)
.orderBy('cdate', 'desc')
.onSnapshot()

Javascript

Click To Expand

#### `package.json`:

#  "@react-native-firebase/app": "^8.2.0",
    "@react-native-firebase/auth": "^8.2.0",
    "@react-native-firebase/firestore": "^7.7.0",
    "@react-native-firebase/messaging": "^7.4.2",
    "@react-native-firebase/storage": "^7.2.2",
    "@react-navigation/bottom-tabs": "^5.7.2",
    "@react-navigation/drawer": "^5.8.6",
    "@react-navigation/native": "^5.7.1",
    "@react-navigation/stack": "^5.7.1",
    "react": "16.13.1",
    "react-native": "0.63.1",
#### `firebase.json` for react-native-firebase v6:
# N/A
### iOS
Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [ x] I'm using Pods and my Podfile looks like:

# require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'

target 'app' do
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"

  target 'app' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'app-tvOS' do
  # Pods for app-tvOS

  target 'app-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end
#### `AppDelegate.m`:
// N/A


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`:

// N/A
#### `android/app/build.gradle`:
// N/A
#### `android/settings.gradle`:
// N/A
#### `MainApplication.java`:
// N/A
#### `AndroidManifest.xml`:
<!-- N/A -->


Environment

Click To Expand

**`react-native info` output:**

 OUTPUT GOES HERE
- **Platform that you're experiencing the issue on**: - [ ] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `e.g. 5.4.3` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `Y/N` & `VERSION`




Needs Triage Bug Stale

All 8 comments

So the test here is: if you completely clear data+cache on the device and uninstall the app, then the next time you install it, do you still see the unexpected / should-not-be-authorized data? The caching hypothesis means that with a clean install you should see the rules applied correctly. With possibly-cached data you might possibly see the cached data on read

Ok, it seems it was the cache data as you guys said. Thank you for your help. I will need to clear cache then when user logs out.

@Solerx I will be curious to see what works with regard to clearing cache - is it sufficient to setOfflinePersistence to false? Or do you have to setCacheSize to 0, or ? It seems to me that if you use the firestore APIs toggle offline persistence off and on it should work, but I'm not sure? Other users may run into this in the future though, so a confirmed working solution would be a help

Cheers

@mikehardy I just set the store to its initials and that worked pretty well for me. Now im trying to Archive and send to TestFlight but im getting a error Use of unresolved identifier 'FIRApp' in if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}

'npx react-native-clean-project' I think. That line that errored is the most fundamental firebase integration step, it's practically the first thing in the docs, it should work

Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

Was this page helpful?
0 / 5 - 0 ratings