Closed angdry closed 1 year ago
I don't believe react-native-firebase has this problem natively, I'll need to see a minimal reproduction that exposes the problem (https://stackoverflow.com/help/minimal-reproducible-example)
By contrast, I provide a minimal reproducible example of it working, on iOS, with hermes, here: https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh
Which is the basis for the assertion - I don't believe react-native-firebase has this problem ?
Could be coming from another module?
This error has been happening since I added the module, so I don't think it's another module. I also wondered if something was wrong with the initialization of the new NativeEventEmitter().
and, I am trying make-demo.sh. I'll run it and let you know the results.
After creating the demo, I did some searching and found another part. Documented for others who encounter the same error.
Podfile
use_frameworks! :linkage => :static
$RNFirebaseAsStaticFramework = true
inside the target is config = use_native_modules!
below.
Then be sure to pod install
target 'YOUR APP' do
config = use_native_modules!
use_frameworks! :linkage => :static
$RNFirebaseAsStaticFramework = true
AppDelegate.mm
Instead of using [FIRApp configure]
alone, write if ([FIRApp defaultApp] == nil) { [FIRApp configure]; }
.
The static frameworks stuff is on rnfirebase.io in the ios install section I think?
Instead of using [FIRApp configure] alone, write if ([FIRApp defaultApp] == nil) { [FIRApp configure]; }.
I think this is a matter of taste, most people don't need it and can just go as documented on rnfirebase.io
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 attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Maybe something like this in your AppComponentFile.js
could work...
But change the package name
let HMSAvailability = null;
let ErrorCode = null;
if (Platform.OS === 'android') {
HMSAvailability = require('@hmscore/react-native-hms-availability').default;
ErrorCode = require('@hmscore/react-native-hms-availability').ErrorCode;
}
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 attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
got the solution or not. I have same issue
i'm scratching my head for several hours now and having the same issue on this as well; i have been replicating make-demo.sh pod file and structure but haven't been able to figure out what's happening.
I solved this by creating a file.android.tsx and file.ios.tsx where the import for react-native-firebase only occurs in the file.android.tsx
I solved this by creating a file.android.tsx and file.ios.tsx where the import for react-native-firebase only occurs in the file.android.tsx
Can you provide a code sample for both ios and android?
I am noticing the same issue. Simply including the module on my page causes the crash. If I comment out the import in my JS file, the app runs fine
Edit:
Ah, I'm stupid, I was trying to use it from an Expo managed project.... I asked ChatGPT:
Me to ChatGPT:
If I add this line on my page, I see the error:
import auth from '@react-native-firebase/auth';
If I comment out that line, the app runs as expected.
ChatGPT's response:
Ah, this sheds some light on the situation.
When you're using an Expo managed project, you're limited to the libraries that Expo supports out of the box. The @react-native-firebase/auth package is a native module, which means it has native code that needs to be linked to your project. Expo managed projects don't support arbitrary native modules.
However, if you're set on using @react-native-firebase/auth (or other packages that require native linking) within an Expo project, you have a couple of options:
Eject from Expo: You can eject from Expo to a "bare" React Native project. This gives you full control over the native side of your project, allowing you to link any native module. However, by doing this, you'll lose some of the conveniences that come with the Expo managed workflow. To eject, run expo eject
Expo Firebase Authentication: If you'd rather stay in the Expo ecosystem, you can use Expo's Firebase authentication method. Expo offers built-in Firebase authentication without needing to eject, but the setup and usage might differ slightly from the @react-native-firebase/auth library.
If you opt for the first choice and eject, remember to read the documentation for any package you want to use (in this case, @react-native-firebase/auth) to ensure proper setup after ejecting.
If you're just looking for Firebase authentication and don't need any specific features provided by @react-native-firebase/auth, I'd recommend sticking with Expo's method. It's more streamlined for the Expo environment, and you won't need to worry about managing native code.
Long story short: I switched to using firebase/auth
package instead.
Sometimes just resarting your device may even help.
did anyone find any solution I am also facing the same issue
same issue
Same issue. Did any one found any solution for this?
This issue is closed and won't receive attention, I suggest opening a new issue and providing enough information to help. Note my response in one of the earliest comments on this thread:
I don't believe react-native-firebase has this problem natively, I'll need to see a minimal reproduction that exposes the problem (https://stackoverflow.com/help/minimal-reproducible-example)
By contrast, I provide a minimal reproducible example of it working, on iOS, with hermes, here: https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh
Which is the basis for the assertion - I don't believe react-native-firebase has this problem ?
Could be coming from another module?
The issue is from messaging for me. import messaging from '@react-native-firebase/messaging';
async function requestUserPermission() { const authStatus = await messaging().requestPermission(); }
when I call messaging error Invariant Violation:
new NativeEventEmitter()requires a non-null argument., js engine: hermes
when I comment out requestUserPermission no error
I get the same thing @EskimoEmoji . I am using Expo managed service.
I encountered this same issue, and it seems for me that deleting the app from the iOS Simulator resolved the issue. Make sure that you run expo prebuild --clean as well.
try add pod 'FirebaseCore', :modular_headers => true in Podfile pod install and rebuilding
The issue is from messaging for me. import messaging from '@react-native-firebase/messaging';
async function requestUserPermission() { const authStatus = await messaging().requestPermission(); }
when I call messaging error
Invariant Violation:
new NativeEventEmitter()requires a non-null argument., js engine: hermes
when I comment out requestUserPermission no error
I am having the same issue on only iOS after adding react-native-background-fetch
🤔
Same issue on Expo managed
Hi, I'm getting the same kind of issue
`Invariant Violation: `new NativeEventEmitter()` requires a non-null argument., js engine: hermes
ERROR Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes`
Please help
I was getting this error, and running expo prebuild
fixed it for me.
If prebuild fails due to a missing googleServicesFile
for android (if developing only iOS), create an empty ./google-services.json
file and point expo.android.googleServicesFile
to it in app.json
.
I encountered this same issue, and it seems for me that deleting the app from the iOS Simulator resolved the issue. Make sure that you run expo prebuild --clean as well.
I was using two simulators; one had an outdated build. After I deleted it, everything worked fine
Issue
Android's Fine. Easy to collect data. But iOS is get err message.
Project Files
Javascript
Click To Expand
#### `package.json`: ```json { "name": "wisetracker_tester", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest", "clean": "react-native-clean-project" }, "dependencies": { "@emotion/react": "^11.10.5", "@emotion/styled": "^11.10.5", "@mui/icons-material": "^5.11.0", "@mui/material": "^5.11.8", "@react-native-async-storage/async-storage": "^1.17.11", "@react-native-camera-roll/camera-roll": "^5.2.3", "@react-native-community/datetimepicker": "^6.7.4", "@react-native-community/push-notification-ios": "^1.10.1", "@react-native-community/segmented-control": "^2.2.2", "@react-native-community/slider": "^4.4.2", "@react-native-firebase/analytics": "^17.3.0", "@react-native-firebase/app": "^17.3.0", "@react-native-picker/picker": "^2.4.8", "@react-navigation/native": "^6.1.3", "@react-navigation/native-stack": "^6.9.9", "@sparkfabrik/react-native-idfa-aaid": "^1.0.0", "DotReactNativeBridge": "github:WisetrackerTechteam/RW-react-package", "axios": "^1.3.0", "http-proxy-middleware": "^2.0.6", "nativewind": "^2.0.11", "react": "18.2.0", "react-devtools": "^4.27.1", "react-dom": "^18.2.0", "react-hook-form": "^7.43.0", "react-native": "0.71.1", "react-native-gesture-handler": "^2.9.0", "react-native-public-ip": "^1.0.2", "react-native-push-notification": "^8.1.1", "react-native-safe-area-context": "^4.5.0", "react-native-screens": "^3.19.0", "react-native-splash-screen": "^3.3.0", "react-native-svg": "^13.7.0", "react-native-svg-transformer": "^1.0.0", "react-native-tracking-transparency": "^0.1.2", "react-native-vector-icons": "^9.2.0", "react-native-woodpicker": "^0.3.17" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native-community/eslint-config": "^3.0.0", "@tsconfig/react-native": "^2.0.2", "@types/jest": "^29.2.1", "@types/react": "^18.0.24", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.2.1", "eslint": "^8.19.0", "file-loader": "^6.2.0", "jest": "^29.2.1", "metro-react-native-babel-preset": "0.73.7", "prettier": "^2.4.1", "react-native-clean-project": "^4.0.1", "react-test-renderer": "18.2.0", "tailwindcss": "^3.2.4", "typescript": "4.8.4" }, "jest": { "preset": "react-native" } } ``` #### `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 require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, min_ios_version_supported prepare_react_native_project! # $RNFirebaseAsStaticFramework = true # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded # # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` # ```js # module.exports = { # dependencies: { # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), # ``` flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym # use_frameworks! :linkage => :static end target 'wisetracker_tester' do use_frameworks! :linkage => :static $RNFirebaseAsStaticFramework = true config = use_native_modules! pod 'GoogleUtilities', :modular_headers => true # Flags change depending on the env values. flags = get_default_flags() use_react_native!( :path => config[:reactNativePath], # Hermes is now enabled by default. Disable by setting this flag to false. # Upcoming versions of React Native may rely on get_default_flags(), but # we make it explicit here to aid in the React Native upgrade process. :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. :flipper_configuration => flipper_config, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) use_frameworks! :linkage => :static $RNFirebaseAsStaticFramework = true target 'wisetracker_testerTests' do inherit! :complete # Pods for testing end post_install do |installer| react_native_post_install( installer, # Set `mac_catalyst_enabled` to `true` in order to apply patches # necessary for Mac Catalyst builds :mac_catalyst_enabled => false ) __apply_Xcode_12_5_M1_post_install_workaround(installer) end # Wisetracker SDK add pod 'RW', '~> 1.1.33' end ``` #### `AppDelegate.m`: ```objc #import "AppDelegate.h" #import
#import
#import "DotReactBridge.h"
#import
#import "RNSplashScreen.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
self.moduleName = @"wisetracker_tester";
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};
[super application:application didFinishLaunchingWithOptions:launchOptions];
[RNSplashScreen show]; // here
// #############################################################
// S: Wisetracker SDK init
[DOT initialization:launchOptions application:application];
#ifdef DEBUG
[DOT checkDebugMode:true];
#else
[DOT checkDebugMode:false];
#endif
// E: Wisetracker SDK init
// #############################################################
return YES;
}
- (NSArray> *)extraModulesForBridge:(RCTBridge *)bridge
{
// If you'd like to export some custom RCTBridgeModules, add them here!
DotReactBridge *dotReactBridge = [DotReactBridge alloc];
return @[dotReactBridge];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
///
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
/// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
- (BOOL)concurrentRootEnabled
{
return true;
}
@end
```
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:** ``` System: OS: macOS 13.1 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 3.79 GB / 32.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.4.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.12.1 - /usr/local/bin/npm Watchman: 2023.02.13.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 11.0.11 - /Users/angdry/.jenv/shims/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.1 => 0.71.1 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:** - `e.g. 17.3.0` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Analytics` - **Are you using `TypeScript`?** - `N` & `VERSION`
React Native Firebase
andInvertase
on Twitter for updates on the library.