Open birdofpreyru opened 2 weeks ago
Ok, I found not yet merged PR #7688, which is related to the init failure.
i tried applying the patch from this PR https://github.com/invertase/react-native-firebase/pull/7688 but still the error persists
@harisbaig100 that is a mediocre patch :rofl: Hold on, I have a working patch at hands, just need a bit more time to clean it up before sharing.
Sure, please do share it, i'm waiting for that, my target platform is ios not android
Here you go:
diff --git a/node_modules/@react-native-firebase/app/lib/internal/registry/nativeModule.js b/node_modules/@react-native-firebase/app/lib/internal/registry/nativeModule.js
index 03f001c..23d467d 100644
--- a/node_modules/@react-native-firebase/app/lib/internal/registry/nativeModule.js
+++ b/node_modules/@react-native-firebase/app/lib/internal/registry/nativeModule.js
@@ -65,7 +65,7 @@ function nativeModuleWrapped(namespace, NativeModule, argToPrepend) {
return NativeModule;
}
- const properties = Object.keys(NativeModule);
+ const properties = Object.keys(Object.getPrototypeOf(NativeModule));
for (let i = 0, len = properties.length; i < len; i++) {
const property = properties[i];
now it says this error
[TypeError: nativeModule.getConstants is not a function. (In 'nativeModule.getConstants()', 'nativeModule.getConstants' is undefined)]
can you tell what version of the packages you are using, i'm using these :
"@react-native-firebase/app": "^15.3.0",
"@react-native-firebase/crashlytics": "^15.3.0",
"@react-native-firebase/messaging": "^15.3.0",
updated the @react-native-firebase/app to 19.2 now the patch is applied let me check if it works
on pod installation now this issue appears
[!] The following Swift pods cannot yet be integrated as static libraries:
The Swift pod `FirebaseCrashlytics` depends upon `FirebaseInstallations`, `GoogleDataTransport`, and `nanopb`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
The Swift pod `FirebaseSessions` depends upon `FirebaseCoreExtension`, `FirebaseInstallations`, `GoogleDataTransport`, and `nanopb`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
I forgot to mention it here, so far I only tested it for Android.
okay ... trying to fix it for ios.
android is not loading it's an instant crash ...
Well, if you just bumped library major version from v15 to v19 chances are it is crashing for unrelated reason, because something had to change with the setup in-between π€·ββοΈ
The error is still the same after fixing all the issues
[Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()]
Are you sure the code is actually re-build, and you don't get the old one from some cache? Try to add some console logging around the patched string, and check whether you see it in the logs, and what actually is returned by that patched method for modules you need.
yeah i checked, there were few undefined and an empty object as well, still looking into that
0.74 + Bridgeless mode is broken on iOS too.
So yeah... if it does not work for you @harisbaig100 , and you saw [TypeError: nativeModule.getConstants is not a function. (In 'nativeModule.getConstants()', 'nativeModule.getConstants' is undefined)]
error with the previous version of the patch... I guess you have the bridgeless mode disabled in your app — I've just disabled it in mine, because of different issues I found, and now my patch does not quite help :)
This one, presumably, should work both in bridge-less and bridge-enabled modes:
diff --git a/node_modules/@react-native-firebase/app/lib/internal/registry/nativeModule.js b/node_modules/@react-native-firebase/app/lib/internal/registry/nativeModule.js
index 03f001c..bd0a484 100644
--- a/node_modules/@react-native-firebase/app/lib/internal/registry/nativeModule.js
+++ b/node_modules/@react-native-firebase/app/lib/internal/registry/nativeModule.js
@@ -65,7 +65,8 @@ function nativeModuleWrapped(namespace, NativeModule, argToPrepend) {
return NativeModule;
}
- const properties = Object.keys(NativeModule);
+ let properties = Object.keys(Object.getPrototypeOf(NativeModule));
+ if (!properties.length) properties = Object.keys(NativeModule);
for (let i = 0, len = properties.length; i < len; i++) {
const property = properties[i];
this is working
function nativeModuleWrapped(namespace, NativeModule, argToPrepend) { const native = NativeModule; if (!NativeModule) { return NativeModule; }
let properties = Object.keys(Object.getPrototypeOf(NativeModule)); if (!properties.length) properties = Object.keys(NativeModule);
// const properties = Object.keys(NativeModule);
for (let i = 0, len = properties.length; i < len; i++) { const property = properties[i]; if (typeof NativeModule[property] === 'function') { native[property] = nativeModuleMethodWrapped(namespace, NativeModule[property], argToPrepend); } else { native[property] = NativeModule[property]; } }
return native; }
My problem seems to be a different issue, but after upgrading to react-native 0.74.1, auth().onAuthStateChanged doesn't work on hot-reload.
useEffect(() => {
console.log({ AuthenticationProvider: 'init.' });
const authListener = auth().onAuthStateChanged(async (firebaseUser) => {
console.log({ firebaseUser });
try {
if (!firebaseUser) {
setUser(firebaseUser);
setAuthenticating(false);
} else {
const customIdToken = await firebaseUser.getIdToken();
keystore.set('token', customIdToken);
setUser(firebaseUser);
setAuthenticating(false);
}
} catch (error) {
console.error('Auth state change error: ', error);
setAuthenticating(false);
}
});
return () => authListener();
}, []);
In the above code, it logs up to AuthenticationProvider, but nothing happens inside onAuthStateChanged. If you close and restart the app completely, it works again π€
@jieey1140 donβt you have this problem: https://github.com/facebook/react-native/issues/44555? Like everything works at first, but at some moment promises from naive side just do not resolve not reject anymore on JS side?
Thank you @birdofpreyru for the patch! I released it as the last non-breaking change on react-native-firebase v19 before I merged and released the breaking changes in v20 in case that helps people test before trying to move to v20 here
(although the breaking changes in v20 were literally all just "you need newer Xcode" and "you need higher minSdk for android" so not too difficult I hope)
I'll note that android seemed to work in my testing but ios did not. I believe the ios problem was local to me but I would love to hear any success reports or failure reports on react-native-firebase v20
No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
Hey folks,
We're scratching our heads for 3 days now. We're facing this issue even with RN - ^0.73.6
and RNFirebase ^19.0.0
.
I'm on Expo 50 and I do not find newArchEnabled
anywhere in my codebase, so I assume I'm still using old architecture? Everything works fine for Android, and the error only started on iOS about a couple of days ago.
Any pointers? I'm happy to get it to "just work" for now with 0.73.6 and will patiently wait for a stable update to migrate to 0.74 later.
Fixed it (iOS, old architecture only).
We found out that this was somehow lost recently, and adding it back fixed it.
Has anybody tested the library with the latest RN@0.74? I've just rapidly tried to upgrade my existing app, which depends on
react-native-firebase
from RN@0.73.6 to RN@0.74.1, and after the upgrade on Android (New Architecture) it tells(which, I believe is supposed to happen automatically, thus I assume it fails to initialize for RN@0.74).
Also, what is the status of the new architecture support? With RN@0.73 the library works for me in an app using the new architecture on Android; but if I am not missing anything, it does not work alongside the new arch on iOS. The new arch has been around for a while now, and it is supported by most popular RN libraries... this one not supporting it is quite a bummer.