Closed Yonom closed 3 years ago
Hi there! This is a duplicate of #3004 - unfortunately the only known workaround at the moment is to use strings. We believe the root cause to be some underlying conversion issue between the IEEE floating point number representation in javascript colliding with a non-floating-point number representation in iOS, so what you think the number is, is not the actual number being fetched (e.g., you think "3", but really it's "3.00000003" or similar because of floating point, while iOS is really looking for "3" as an integer)
We do not have a fix at the moment
@mikehardy Thank you for pointing me in the right direction. (And sorry about the duplicate, I didn't catch that one 😊)
It seems unlikely that this has something to do with IEEE rounding given the fact that I am using integers (and 123 can be represented with perfect accuracy as float, double, json, etc.). I will dig around in obj-c code and if I find the root cause, submit a fix
@Yonom if you could find a fix for this one that would be seriously fantastic!
Issue
Using
firestore.collection('myCollection').where('myNumberField', 'in', [123])
returns an empty array on iOS.Example:
Project Files
Javascript
Click To Expand
#### `package.json`: ```json { "main": "index.js", "scripts": { "android": "expo run:android", "ios": "expo run:ios", "web": "expo start --web", "start": "expo start --dev-client", }, "dependencies": { "@invertase/react-native-apple-authentication": "^2.1.5", "@react-native-async-storage/async-storage": "^1.15.9", "@react-native-clipboard/clipboard": "^1.9.0", "@react-native-community/blur": "^3.6.0", "@react-native-community/netinfo": "^6.0.5", "@react-native-firebase/analytics": "^13.0.1", "@react-native-firebase/app": "^13.0.1", "@react-native-firebase/auth": "^13.0.1", "@react-native-firebase/crashlytics": "^13.0.1", "@react-native-firebase/dynamic-links": "^13.0.1", "@react-native-firebase/firestore": "^13.0.1", "@react-native-firebase/in-app-messaging": "^13.0.1", "@react-native-firebase/messaging": "^13.0.1", "@react-native-firebase/perf": "^13.0.1", "@react-native-firebase/remote-config": "^13.0.1", "@react-native-firebase/storage": "^13.0.1", "@react-native-google-signin/google-signin": "^7.0.1", "@react-navigation/bottom-tabs": "^6.0.9", "@react-navigation/native": "^6.0.6", "@react-navigation/stack": "^6.0.11", "expo": "^43.0.1", "expo-asset": "^8.4.3", "expo-constants": "^12.1.3", "expo-dev-client": "^0.6.3", "expo-file-system": "^13.0.3", "expo-font": "^10.0.3", "expo-splash-screen": "^0.13.5", "expo-status-bar": "^1.1.0", "expo-updates": "^0.10.13", "lottie-ios": "^3.2.3", "lottie-react-native": "^4.1.3", "patch-package": "^6.4.7", "postinstall-postinstall": "^2.1.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-firebase-hooks": "^3.0.4", "react-native": "^0.66.2", "react-native-fbsdk-next": "^4.6.0", "react-native-gesture-handler": "^1.10.3", "react-native-reanimated": "^2.2.3", "react-native-safe-area-context": "^3.3.2", "react-native-screens": "^3.9.0", "react-native-web": "^0.17.5" }, "devDependencies": { "@babel/core": "^7.16.0", "@types/react": "^17.0.34", "@types/react-native": "^0.66.2", "@typescript-eslint/eslint-plugin": "^5.3.0", "@typescript-eslint/parser": "^5.3.0", "eslint": "^8.2.0", "eslint-config-airbnb": "^18.2.1", "eslint-config-airbnb-typescript": "^15.0.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "^2.25.2", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-react": "^7.26.1", "eslint-plugin-react-hooks": "^4.2.1-alpha-c3a19e5af-20211014", "prettier": "^2.4.1", "typescript": "^4.4.4" }, "prettier": { "singleQuote": true }, "eslintConfig": { "extends": "./tools/react-native.eslintrc.js" }, "private": true, "name": "app", "version": "1.0.0" } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```
iOS
Click To Expand
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # @react-native-firebase/analytics $RNFirebaseAnalyticsWithoutAdIdSupport = true require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking") require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods") require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules") platform :ios, '12.0' require 'json' podfile_properties = JSON.parse(File.read('./Podfile.properties.json')) rescue {} target 'READODev' do use_expo_modules! config = use_native_modules! pod 'expo-dev-launcher', path: '../node_modules/expo-dev-launcher', :configurations => :debug pod 'expo-dev-menu', path: '../node_modules/expo-dev-menu', :configurations => :debug use_react_native!( :path => config[:reactNativePath], :hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes' ) # Uncomment to opt-in to using Flipper # # if !ENV['CI'] # use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1') # end use_flipper!() post_install do |installer| react_native_post_install(installer) # Workaround `Cycle inside FBReactNativeSpec` error for react-native 0.64 # Reference: https://github.com/software-mansion/react-native-screens/issues/842#issuecomment-812543933 installer.pods_project.targets.each do |target| if (target.name&.eql?('FBReactNativeSpec')) target.build_phases.each do |build_phase| if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs')) target.build_phases.move(build_phase, 0) end end end end end end ``` #### `AppDelegate.m`: ```objc #import "AppDelegate.h" #import
#import "RNFBMessagingModule.h"
#if defined(EX_DEV_MENU_ENABLED)
@import EXDevMenu;
#endif
#if defined(EX_DEV_LAUNCHER_ENABLED)
#include
#import
#endif
@import Firebase;
#import
#import
#import
#import
#import
#if defined(FB_SONARKIT_ENABLED) && __has_include()
#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
- (RCTBridge *)initializeReactNativeApp:(NSDictionary *)launchOptions
{
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
// @react-native-firebase/messaging
NSDictionary *appProperties = [RNFBMessagingModule addCustomPropsToUserProps:nil withLaunchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:appProperties];
id rootViewBackgroundColor = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"RCTRootViewBackgroundColor"];
if (rootViewBackgroundColor != nil) {
rootView.backgroundColor = [RCTConvert UIColor:rootViewBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return bridge;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#if defined(FB_SONARKIT_ENABLED) && __has_include()
InitializeFlipper(application);
#endif
// @generated begin @react-native-firebase/app-didFinishLaunchingWithOptions - expo prebuild (DO NOT MODIFY) sync-ecd111c37e49fdd1ed6354203cd6b1e2a38cccda
[FIRApp configure];
// @generated end @react-native-firebase/app-didFinishLaunchingWithOptions
[[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
#if defined(EX_DEV_LAUNCHER_ENABLED)
EXDevLauncherController *controller = [EXDevLauncherController sharedInstance];
controller.updatesInterface = [EXUpdatesDevLauncherController sharedInstance];
[controller startWithWindow:self.window delegate:(id)self launchOptions:launchOptions];
#else
[self initializeReactNativeApp:launchOptions];
#endif
[super application:application didFinishLaunchingWithOptions:launchOptions];
return YES;
}
- (NSArray> *)extraModulesForBridge:(RCTBridge *)bridge
{
// If you'd like to export some custom RCTBridgeModules, add them here!
return @[];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#ifdef DEBUG
#if defined(EX_DEV_LAUNCHER_ENABLED)
return [[EXDevLauncherController sharedInstance] sourceUrl];
#else
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#endif
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// react-native-fbsdk-next
[FBSDKAppEvents activateApp];
}
// Linking API
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options {
// react-native-fbsdk-next
if ([[FBSDKApplicationDelegate sharedInstance] application:application openURL:url options:options]) {
return YES;
}
#if defined(EX_DEV_LAUNCHER_ENABLED)
if ([EXDevLauncherController.sharedInstance onDeepLink:url options:options]) {
return true;
}
#endif
return [RCTLinkingManager application:application openURL:url options:options];
}
// Universal Links
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler {
return [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}
@end
#if defined(EX_DEV_LAUNCHER_ENABLED)
@implementation AppDelegate (EXDevLauncherControllerDelegate)
- (void)devLauncherController:(EXDevLauncherController *)developmentClientController
didStartWithSuccess:(BOOL)success
{
developmentClientController.appBridge = [self initializeReactNativeApp:[EXDevLauncherController.sharedInstance getLaunchOptions]];
}
@end
#endif
```
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`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```
Environment
Click To Expand
**`react-native info` output:** ``` ❯ npx react-native info info Fetching system and libraries information... System: OS: macOS 11.6 CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz Memory: 174.70 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.0 - /usr/local/Cellar/node@16/16.13.0/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 8.1.0 - /usr/local/Cellar/node@16/16.13.0/bin/npm Watchman: 2021.10.18.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0 Android SDK: API Levels: 23, 24, 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 31.0.0, 31.0.0, 31.0.0, 31.0.0 System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7784292 Xcode: 13.1/13A1030d - /usr/bin/xcodebuild Languages: Java: 1.8.0_292 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: ^17.0.2 => 17.0.2 react-native: ^0.66.2 => 0.66.2 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **Platform that you're experiencing the issue on**: - [x] 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:** - 12.8.0 - 13.0.0 - 13.0.1 - **`Firebase` module(s) you're using that has the issue:** - `firestore` - **Are you using `TypeScript`?** - `Y` & `4.4.4`
React Native Firebase
andInvertase
on Twitter for updates on the library.