invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.7k stars 2.22k forks source link

[🐛] firebase database does not return current value #6112

Closed deflexable closed 2 years ago

deflexable commented 2 years ago

Issue

Describe your issue here

Hello, we have an app live on both playstore and appstore which uses rnfirebase database. User list doesn't get updated with current changes from the database. we're currently using database persistence. When i read a list from the database for the first time, firebase returns current result from the database and caches it. Whenever i read the same list after it has change in the database, firebase doesn't return the changed list in the database but keeps returning initial cached data gotten from the first read operation.

my database structure:

{"users" : {
      "Dv0YkEFj4cc0VlcDDQIdJO99pND2" : {
      "email" : "XXXXXX@gmail.com",
      "img" : "https://lh3.googleusercontent.com/a-/AOh14GjA_VIccAb17UWIGmvNNJ0F5xuDH1npsn3iENC6DCY=s96-c",
      "name" : "XXXXXX",
      "nameL" : "XXXXXX",
      "status" : 1644983691797
    },
    "EBOYld3ly7dIvhqWgyRTzpATrzP2" : {
      "email" : "XXXXXX@gmail.com",
      "img" : "https://lh3.googleusercontent.com/a-/AOh14GjD3zlnBgEsip2BPIlas3J4vlL6SzFhP6aQwIovCw=s96-c",
      "name" : "XXXXXX",
      "nameL" : "XXXXXX",
      "status" : 1645422362462
    },
    "FMuaPeDofUeGmaexs39DZbwXEQm2" : {
      "email" : "XXXXXX@gmail.com",
      "img" : "https://lh3.googleusercontent.com/a-/AOh14GhT9tbzB1gqEGQT4_PEv5Z5BdOIRNTq4QKPxNREiQ=s96-c",
      "name" : "XXXXXX",
      "nameL" : "XXXXXX",
      "status" : 1646428416318
    },
    "K3hSk8qBuvOS8bbao71n8wTGeMX2" : {
      "email" : "XXXXXX@gmail.com",
      "img" : "https://lh3.googleusercontent.com/a-/AOh14GhfLufr6tSOQ74Bak4b8oVb-92XjaDdKCS_2Ee0IQ=s96-c",
      "name" : "XXXXXX",
      "nameL" : "XXXXXX",
      "status" : 1646359354698
    },
    "N4fSkx9se2bZMJze49mkZsBkt9w1" : {
      "deleted" : true,
      "email" : "XXXXXX@blazingcrown.com",
      "name" : "XXXXXX",
      "nameL" : "XXXXXX",
      "status" : "online"
    },
    "N8rRKoHByKMvVL6FYUrZQVlOKbn1" : {
      "email" : "XXXXXX@gmail.com",
      "img" : "https://lh3.googleusercontent.com/a-/AOh14GjcYgaZrXAbeUgFDQrTU9x5zT09WV8kAw-83ha0YqE=s96-c",
      "name" : "XXXXXX",
      "nameL" : "XXXXXX",
      "status" : 1644984970455
    },
    "SFXxpoip0lXTS2wx90jePGLj39I2" : {
      "email" : "XXXXXX@gmail.com",
      "img" : "https://firebasestorage.googleapis.com:443/v0/b/heavenya.appspot.com/o/users%2FSFXxpoip0lXTS2wx90jePGLj39I2%2FprofilePic.png?alt=media&token=20adb723-35b2-41c2-a0e9-e04d2f7effb9",
      "name" : "XXXXXX",
      "nameL" : "XXXXXX",
      "status" : 1646533766400
    }
}

code for reading data:

database().ref('users').orderByKey().limitToLast(100).once('value', snapshot=>{
       console.log('user size', snapshot.numChildren()); // returns 7 but user list already increase to 20
 });

If a new user was added to the database, this changes will not be returned in the client

Playstore url : https://play.google.com/store/apps/details?id=com.faithful.heavenya Appstore url : https://apps.apple.com/us/app/heavenya-christian-fellowship/id1498340882


Project Files

Javascript

Click To Expand

#### `package.json`: ```json { "name": "heavenya_app", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint .", "postinstall": "patch-package", "android-bundle": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle", "android-release-aab": "yarn android-bundle && cd android && ./gradlew clean && ./gradlew bundleRelease", "android-release-apk": "yarn android-bundle && cd android && ./gradlew clean && ./gradlew assembleRelease", "ios-setup": "yarn install && cd ios && rm Podfile.lock && rm -rf Pods && pod install --repo-update && cd .. && yarn ios", "android-setup": "yarn install && yarn android" }, "dependencies": { "@ant-design/react-native": "^4.2.0", "@invertase/react-native-apple-authentication": "^2.1.2", "@ptomasroos/react-native-multi-slider": "^2.2.2", "@react-native-async-storage/async-storage": "^1.15.15", "@react-native-community/cameraroll": "^4.0.4", "@react-native-community/clipboard": "^1.5.1", "@react-native-community/datetimepicker": "^3.5.2", "@react-native-community/geolocation": "^2.0.2", "@react-native-community/masked-view": "^0.1.11", "@react-native-community/push-notification-ios": "^1.10.0", "@react-native-community/segmented-control": "^2.2.2", "@react-native-community/slider": "^4.1.1", "@react-native-firebase/analytics": "^14.5.0", "@react-native-firebase/app": "^14.5.0", "@react-native-firebase/auth": "^14.5.0", "@react-native-firebase/crashlytics": "^14.5.1", "@react-native-firebase/database": "^14.5.0", "@react-native-firebase/messaging": "^14.5.0", "@react-native-firebase/storage": "^14.5.0", "@react-native-google-signin/google-signin": "^7.0.4", "@react-native-picker/picker": "^2.2.1", "@react-navigation/bottom-tabs": "^6.0.5", "@react-navigation/native": "^6.0.2", "@react-navigation/stack": "^6.0.7", "geofire": "^5.2.0", "i18n-js": "^3.8.0", "lodash": "^4.17.21", "moment": "^2.29.1", "moment-timezone": "^0.5.33", "patch-package": "^6.4.7", "postinstall-postinstall": "^2.1.0", "react": "17.0.2", "react-native": "0.64.2", "react-native-action-button": "^2.8.5", "react-native-calendars": "1.1274.0", "react-native-collapsible-toolbar": "^0.1.2", "react-native-contacts": "^7.0.3", "react-native-dash": "^0.0.11", "react-native-extended-stylesheet": "^0.12.0", "react-native-fs": "^2.18.0", "react-native-geolocation-service": "^5.3.0-beta.4", "react-native-gesture-handler": "^2.1.1", "react-native-hyperlink": "^0.0.19", "react-native-image-crop-picker": "^0.37.2", "react-native-iphone-x-helper": "^1.3.1", "react-native-linear-gradient": "^2.5.6", "react-native-localize": "^2.1.1", "react-native-maps": "^0.29.4", "react-native-modal-datetime-picker": "^13.0.1", "react-native-modalbox": "2.0.2", "react-native-pager-view": "^5.4.0", "react-native-permissions": "^3.0.5", "react-native-push-notification": "^8.0.0", "react-native-reanimated": "2.2.0", "react-native-root-siblings": "^4.1.1", "react-native-root-toast": "^3.2.1", "react-native-safe-area-context": "^3.3.0", "react-native-screens": "^3.5.0", "react-native-share": "^7.3.3", "react-native-snap-carousel": "^3.9.1", "react-native-spinkit": "^1.5.1", "react-native-splash-screen": "^3.2.0", "react-native-star-rating": "^1.1.0", "react-native-svg": "^12.1.1", "react-native-swipe-list-view": "^3.2.9", "react-native-swipeout": "^2.3.6", "react-native-switch": "^2.0.0", "react-native-vector-icons": "^9.0.0", "react-native-video": "^5.1.1", "react-native-view-shot": "^3.1.2", "react-native-webview": "^11.13.0", "reanimated-bottom-sheet": "^1.0.0-alpha.22", "socket.io-client": "2.3.0", "xdate": "^0.8.2" }, "devDependencies": { "@babel/core": "^7.14.8", "@babel/runtime": "^7.14.8", "@react-native-community/eslint-config": "^3.0.0", "babel-jest": "^27.0.6", "babel-plugin-transform-remove-console": "^6.9.4", "eslint": "8.6.0", "jest": "^27.0.6", "metro-react-native-babel-preset": "^0.66.2", "react-test-renderer": "17.0.2" }, "jest": { "preset": "react-native" } } ``` #### `firebase.json` for react-native-firebase v6: ```json { "react-native": { "messaging_android_notification_channel_id": "high-priority", "messaging_android_notification_color": "@color/skyblue", "crashlytics_debug_enabled": true } } ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, '11.0' $RNFirebaseAnalyticsWithoutAdIdSupport = true target 'heavenya_app' do config = use_native_modules! permissions_path = '../node_modules/react-native-permissions/ios' use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods :hermes_enabled => true ) pod 'react-native-google-maps', :path => '../node_modules/react-native-maps' pod 'GoogleMaps' pod 'Google-Maps-iOS-Utils' pod 'GoogleSignIn', '~> 6.0.0' pod 'Permission-Camera', :path => "#{permissions_path}/Camera" pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary" pod 'Permission-PhotoLibraryAddOnly', :path => "#{permissions_path}/PhotoLibraryAddOnly" target 'heavenya_appTests' 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!() # use_flipper!({ 'Flipper' => '0.128.4' }) # use_flipper!({ 'Flipper' => '0.74.0' }) # post_install do |installer| # react_native_post_install(installer) # end post_install do |installer| react_native_post_install(installer) # installer.pods_project.targets.each do |target| # target.build_configurations.each do |config| # config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0' # end # end end end # target 'OneSignalNotificationServiceExtension' do # pod 'OneSignal', '>= 3.0', '< 4.0' # end target 'heavenya_app-tvOS' do # Pods for heavenya_app-tvOS target 'heavenya_app-tvOSTests' do inherit! :search_paths # Pods for testing end end # post_install do |installer| # installer.pods_project.targets.each do |target| # target.build_configurations.each do |config| # config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0' # end # end # end ``` #### `AppDelegate.m`: ```objc #import "AppDelegate.h" #import #import #import #import #import "RNSplashScreen.h" #import #import #import #import #import #ifdef FB_SONARKIT_ENABLED #import #import #import #import #import #import static void InitializeFlipper(UIApplication *application) { FlipperClient *client = [FlipperClient sharedClient]; SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; [client addPlugin:[FlipperKitReactPlugin new]]; [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; [client start]; } #endif @implementation AppDelegate - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; } // Only if your app is using [Universal Links](https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html). - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler { return [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; } // Required to register for notifications - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings]; } // Required for the register event. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; } // Required for the notification event. You must call the completion handler after handling the remote notification. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; } // Required for the registrationError event. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error]; } // Required for the localNotification event. - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { [RNCPushNotificationIOS didReceiveLocalNotification:notification]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { #ifdef FB_SONARKIT_ENABLED InitializeFlipper(application); #endif [FIRApp configure]; RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"com.faithful.heavenya" initialProperties:nil]; if (@available(iOS 13.0, *)) { rootView.backgroundColor = [UIColor systemBackgroundColor]; } else { rootView.backgroundColor = [UIColor whiteColor]; } // define UNUserNotificationCenter UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self; [GMSServices provideAPIKey:@"AIzaSyD1Sgw6lGuovQB062obSPJsUoF2ECG5Swk"]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; [RNSplashScreen show]; return YES; } //Called when a notification is delivered to a foreground app. -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { NSLog(@"User Info : %@",notification.request.content.userInfo); completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge); } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif } #if RCT_DEV - (BOOL)bridge:(RCTBridge *)bridge didNotFindModule:(NSString *)moduleName { return YES; } #endif @end ```


Android

Click To Expand

#### Have you converted to AndroidX? - [x] 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`: ```groovy // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { buildToolsVersion = "29.0.3" minSdkVersion = 21 compileSdkVersion = 31 targetSdkVersion = 31 ndkVersion = "20.1.5948944" playServicesVersion = "17.0.0" googlePlayServicesAuthVersion = "16.0.1" } repositories { google() jcenter() maven { url 'https://www.jitpack.io' } maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath 'com.android.tools.build:gradle:4.2.1' classpath 'com.google.gms:google-services:4.3.10' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1' // classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.10' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } google() jcenter() maven { url 'https://www.jitpack.io' } maven { url "https://plugins.gradle.org/m2/" } } } ``` #### `android/app/build.gradle`: ```groovy // apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' import com.android.build.OutputFile /** * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets * and bundleReleaseJsAndAssets). * These basically call `react-native bundle` with the correct arguments during the Android build * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the * bundle directly from the development server. Below you can see all the possible configurations * and their defaults. If you decide to add a configuration block, make sure to add it before the * `apply from: "../../node_modules/react-native/react.gradle"` line. * * project.ext.react = [ * // the name of the generated asset file containing your JS bundle * bundleAssetName: "index.android.bundle", * * // the entry file for bundle generation. If none specified and * // "index.android.js" exists, it will be used. Otherwise "index.js" is * // default. Can be overridden with ENTRY_FILE environment variable. * entryFile: "index.android.js", * * // https://reactnative.dev/docs/performance#enable-the-ram-format * bundleCommand: "ram-bundle", * * // whether to bundle JS and assets in debug mode * bundleInDebug: false, * * // whether to bundle JS and assets in release mode * bundleInRelease: true, * * // whether to bundle JS and assets in another build variant (if configured). * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants * // The configuration property can be in the following formats * // 'bundleIn${productFlavor}${buildType}' * // 'bundleIn${buildType}' * // bundleInFreeDebug: true, * // bundleInPaidRelease: true, * // bundleInBeta: true, * * // whether to disable dev mode in custom build variants (by default only disabled in release) * // for example: to disable dev mode in the staging build type (if configured) * devDisabledInStaging: true, * // The configuration property can be in the following formats * // 'devDisabledIn${productFlavor}${buildType}' * // 'devDisabledIn${buildType}' * * // the root of your project, i.e. where "package.json" lives * root: "../../", * * // where to put the JS bundle asset in debug mode * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", * * // where to put the JS bundle asset in release mode * jsBundleDirRelease: "$buildDir/intermediates/assets/release", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in debug mode * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in release mode * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", * * // by default the gradle tasks are skipped if none of the JS files or assets change; this means * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to * // date; if you have any other folders that you want to ignore for performance reasons (gradle * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ * // for example, you might want to remove it from here. * inputExcludes: ["android/**", "ios/**"], * * // override which node gets called and with what additional arguments * nodeExecutableAndArgs: ["node"], * * // supply additional arguments to the packager * extraPackagerArgs: [] * ] */ project.ext.react = [ entryFile: "index.js", enableHermes: true, // clean and rebuild if changing bundleAssetName: "index.android.bundle", bundleInRelease: true, bundleInStaging: true ] apply from: "../../node_modules/react-native/react.gradle" /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = false /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = true /** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and mirrored here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ def enableHermes = project.ext.react.get("enableHermes", true) android { ndkVersion rootProject.ext.ndkVersion compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "com.faithful.heavenya" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 32 versionName "1.16.3" multiDexEnabled true } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk true // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } release { if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) { storeFile file(MYAPP_UPLOAD_STORE_FILE) storePassword MYAPP_UPLOAD_STORE_PASSWORD keyAlias MYAPP_UPLOAD_KEY_ALIAS keyPassword MYAPP_UPLOAD_KEY_PASSWORD } } } buildTypes { debug { signingConfig signingConfigs.debug } release { // Caution! In production, you need to generate your own keystore file. // see https://reactnative.dev/docs/signed-apk-android. signingConfig signingConfigs.release minifyEnabled enableProguardInReleaseBuilds shrinkResources true proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" firebaseCrashlytics { nativeSymbolUploadEnabled true unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib' } } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = defaultConfig.versionCode * 1000 + versionCodes.get(abi) } } } } dependencies { // implementation project(':react-native-reanimated') // implementation project(':react-native-gesture-handler') // implementation project(':react-native-vector-icons') // implementation project(':react-native-maps') // implementation project(':@react-native-community_geolocation') // implementation project(':react-native-onesignal') // implementation project(':@react-native-community_clipboard') // implementation project(':react-native-webview') // implementation project(':@react-native-community_netinfo') // implementation project(':react-native-push-notification') // implementation project(':react-native-spinkit') // implementation project(':react-native-video') // implementation project(':react-native-fast-image') // implementation project(':react-native-splash-screen') // implementation project(':react-native-navybits-date-time-picker') // implementation project(':@react-native-community_async-storage') // implementation project(':react-native-linear-gradient') // implementation project(':react-native-localize') // implementation project(':react-native-share') // implementation project(':react-native-view-shot') // implementation project(':react-native-fs') // implementation project(':react-native-image-crop-picker') // implementation project(':react-native-pager-view') implementation fileTree(dir: "libs", include: ["*.jar"]) implementation platform('com.google.firebase:firebase-bom:29.0.3') // implementation platform('com.google.firebase:firebase-bom:26.5.0') //implementation project(path: ":@react-native-firebase_app") //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation 'com.facebook.fresco:animated-gif:2.0.0' implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01' implementation 'androidx.multidex:multidex:2.0.1' debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/" debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.implementation into 'libs' } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) ``` #### `android/settings.gradle`: ```groovy rootProject.name = 'com.faithful.heavenya' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' ``` #### `MainApplication.java`: ```java package com.faithful.heavenya; import com.facebook.react.bridge.JSIModulePackage; import com.swmansion.reanimated.ReanimatedJSIModulePackage; import android.app.Application; import android.content.Context; import androidx.multidex.MultiDex; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; import java.lang.reflect.InvocationTargetException; import java.util.List; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override protected JSIModulePackage getJSIModulePackage() { return new ReanimatedJSIModulePackage(); } @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for // example: // packages.add(new MyReactNativePackage()); /* * packages.add( new RNFirebaseAuthPackage()); * packages.add(new RNFirebaseMessagingPackage()); * packages.add(new RNFirebaseNotificationsPackage()); */ return packages; } @Override protected String getJSMainModuleName() { return "index"; } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); // Remove this line if you don't want // Flipper enabled } /** * Loads Flipper in React Native templates. Call this in the onCreate method * with something like * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); * * @param context * @param reactInstanceManager */ private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { if (BuildConfig.DEBUG) { try { /* * We use reflection here to pick up the class that initializes Flipper, * since Flipper library is not available in release mode */ Class aClass = Class.forName("com.faithful.heavenya.ReactNativeFlipper"); aClass.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class).invoke(null, context, reactInstanceManager); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } } ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: Windows 10 10.0.19042 CPU: (4) ia32 Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz Memory: 8.98 GB / 15.79 GB Binaries: Node: 16.13.0 - ~\AppData\Local\Temp\yarn--1646604189645-0.8916054103472522\node.CMD Yarn: 1.22.17 - ~\AppData\Local\Temp\yarn--1646604189645-0.8916054103472522\yarn.CMD npm: 8.1.2 - C:\Program Files (x86)\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found Windows SDK: Not Found IDEs: Android Studio: Version 2020.3.0.0 AI-203.7717.56.2031.7784292 Visual Studio: Not Found Languages: Java: 11.0.12 npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.64.2 => 0.64.2 react-native-windows: Not Found npmGlobalPackages: *react-native*: Not Found Done in 19.59s. ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [x] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `^14.5.0` - **`Firebase` module(s) you're using that has the issue:** - `@react-native-firebase/database` - **Are you using `TypeScript`?** - `N`


mikehardy commented 2 years ago

That sounds frustrating - same behavior on android and ios? I'm guessing yes since you posted up both the platforms' information. This seems like it's going to be either a misunderstanding of how the caching/persistence is going to work (does it work with persistence off?) or there is the same bug on both underlying native SDKs (which is...unlikely but possible.

Either way I will guess that in this case react-native-firebase is just going to be the messenger / plumbing here for your results direct from the native SDK and I implore you to try a toy demonstration built (really quickly, I hope) from one of their quickstarts depending on which platform is faster for you to check:

https://github.com/firebase/quickstart-android/tree/master/database https://github.com/firebase/quickstart-ios/tree/master/database

That will really quickly help determine if it's really in this wrapper or if it's in our underlying SDKs, and if you get the same behavior against the underlying SDK direct then I'd pay really careful attention to exactly how it is supposed to behave, this may actually be expected behavior for your API usage / config even if it's unwanted in general, pointing at a need to use things slightly differently

You have posted your structure but what would be more interesting - if the native SDKs don't reproduce, is an App.js that was minimal and self-contained and demonstrated it if we dropped it in a clean skeleton like from https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh (https://stackoverflow.com/help/minimal-reproducible-example)

stale[bot] commented 2 years ago

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.

stale[bot] commented 2 years ago

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.