Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛] RN@0.74 support? #7788

Open
birdofpreyru opened this issue May 12, 2024 · 24 comments
Open

[🐛] RN@0.74 support? #7788

birdofpreyru opened this issue May 12, 2024 · 24 comments
Labels
Workflow: Waiting for User Response Blocked waiting for user response.

Comments

@birdofpreyru
Copy link

birdofpreyru commented May 12, 2024

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

No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()

(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.

@birdofpreyru birdofpreyru added Help: Needs Triage Issue needs additional investigation/triaging. Impact: Bug New bug report labels May 12, 2024
@birdofpreyru
Copy link
Author

Ok, I found not yet merged PR #7688, which is related to the init failure.

@harisbaig100
Copy link

i tried applying the patch from this PR #7688 but still the error persists

@birdofpreyru
Copy link
Author

@harisbaig100 that is a mediocre patch 🤣 Hold on, I have a working patch at hands, just need a bit more time to clean it up before sharing.

@harisbaig100
Copy link

harisbaig100 commented May 13, 2024

Sure, please do share it, i'm waiting for that, my target platform is ios not android

@birdofpreyru
Copy link
Author

birdofpreyru commented May 13, 2024

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];

@harisbaig100
Copy link

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",

@harisbaig100
Copy link

updated the @react-native-firebase/app to 19.2 now the patch is applied let me check if it works

@harisbaig100
Copy link

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.

@birdofpreyru
Copy link
Author

I forgot to mention it here, so far I only tested it for Android.

@harisbaig100
Copy link

okay ... trying to fix it for ios.

@hamdij0maa
Copy link

android is not loading it's an instant crash ...

@birdofpreyru
Copy link
Author

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 🤷‍♂️

@harisbaig100
Copy link

The error is still the same after fixing all the issues

[Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()]

@birdofpreyru
Copy link
Author

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.

@harisbaig100
Copy link

yeah i checked, there were few undefined and an empty object as well, still looking into that

@karimb11
Copy link

0.74 + Bridgeless mode is broken on iOS too.

@birdofpreyru
Copy link
Author

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 :)

@birdofpreyru
Copy link
Author

birdofpreyru commented May 13, 2024

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];

@anujmv
Copy link

anujmv commented May 16, 2024

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;
}

@jieey1140
Copy link

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 🤔

@birdofpreyru
Copy link
Author

@jieey1140 don’t you have this problem: facebook/react-native#44555? Like everything works at first, but at some moment promises from naive side just do not resolve not reject anymore on JS side?

@mikehardy
Copy link
Collaborator

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

@mikehardy mikehardy added Workflow: Waiting for User Response Blocked waiting for user response. and removed Impact: Bug New bug report Help: Needs Triage Issue needs additional investigation/triaging. labels May 20, 2024
@atif089
Copy link

atif089 commented May 24, 2024

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.

@atif089
Copy link

atif089 commented May 29, 2024

Fixed it (iOS, old architecture only).

We found out that this was somehow lost recently, and adding it back fixed it.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Workflow: Waiting for User Response Blocked waiting for user response.
Projects
None yet
Development

No branches or pull requests

8 participants