flyerhq / react-native-firebase-chat-core

Actively maintained, community-driven Firebase BaaS for chat applications with an optional chat UI.
https://flyer.chat
Apache License 2.0
79 stars 17 forks source link

[Expo] Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.app(). #9

Open KMNowak opened 3 years ago

KMNowak commented 3 years ago

General

What bug do you experience? 🐞

While using with Expo 42.0.0, calling fetchUser returns:

Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.app().

How can it be reproduced? πŸ€”

A few steps to define where does the bug occur. Step 1. Create new app with Expo 42. Step 2. Create project in Firebase and add it to the application. Step 3. Sign in (e.g. Anonymously), get user and try call fetchUser(firebaseUser.uid)

What behavior is expected? πŸ’‘

The method fetchUser should be called correctly.


Extras

Code snippets πŸ“

Minimum example:

import React, { useEffect } from 'react'
import firebase from 'firebase'
import { createUserInFirestore, fetchUser } from '@flyerhq/react-native-firebase-chat-core'
import { firebaseConfig } from './config'

const MyComponent = () => {
   useEffect(() => {
      firebase.initializeApp(firebaseConfig)

      const firebaseUser = firebase.auth().currentUser

     if (!firebaseUser) {
       firebase.auth().signInAnonymously()
         .then(newUser =>newUser &&  fetchUser(newUser.uid) // <-- here throws below error
     }
   }, [])

   return (
    <View><Text>Sample</Text></View>
   ) 
}


Environment info

Please specify the react, react-native, react-native-firebase-chat-core versions.

react: 16.13.1 react-native: https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz react-native-firebase-chat-core: 1.0.1

npx react-native info output πŸ‘‡

System:
    OS: macOS 11.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 667.56 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.8.4 - /usr/local/bin/pod
  SDKs:
    iOS SDK: Not Found
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3
      System Images: android-28 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.3 AI-182.5107.16.33.5264788
    Xcode: /undefined - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_201 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz => 0.63.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found


Platform

Device: sm-g781b

OS version Android 11


cristaloleg commented 3 years ago

Looks like issue is missing some details, can you add?

KMNowak commented 3 years ago

Sorry, I accidentally hit enter. Now it's complete :)

KMNowak commented 3 years ago

Now it's complete. I'll be grateful if you can give some insights what can be changed to make it work.

aaryashahk commented 3 years ago

Having the same issue. Correct me if I am wrong, but I believe it has something to do with FlyerChat using the React Native Firebase dependency, separate from the Firebase JS SDK, which is not usable on the managed workflow utilized by Expo.

demchenkoalex commented 3 years ago

Oops completely missed that! We are working on a big update for React Native with new features and Firebase package will be updated too. I will take a look at Expo too.

aaryashahk commented 3 years ago

Oops completely missed that! We are working on a big update for React Native with new features and Firebase package will be updated too. I will take a look at Expo too.

When can we expect this update? And in the meantime, is there anything developers using Expo's managed workflow can do?

demchenkoalex commented 3 years ago

@aaryashahk I have never used Expo before, so I can't suggest anything. PR with an update is already in the UI repo, I just need to find some time to review it, so in the near future.

aaryashahk commented 3 years ago

@aaryashahk I have never used Expo before, so I can't suggest anything. PR with an update is already in the UI repo, I just need to find some time to review it, so in the near future.

I understand. Does this PR with the update that's already in the UI repo have the capability of working with Firebase in Expo's managed workflow?

demchenkoalex commented 3 years ago

@aaryashahk UI and Firebase are not related packages. We separated them completely in order for people to use whatever they want, not requiring the other part. From what I know UI has no problems with Expo whatsoever.

aaryashahk commented 3 years ago

@aaryashahk UI and Firebase are not related packages. We separated them completely in order for people to use whatever they want, not requiring the other part. From what I know UI has no problems with Expo whatsoever.

Yes, UI works perfectly fine on Expo. Incorporating Firebase is the problem in Expo since FlyerChat is using react-native-firebase, which is not compatible with Expo's managed workflow. Are you going to add support for FlyerChat's Firebase BaaS to work on Expo's managed workflow?

demchenkoalex commented 3 years ago

@aaryashahk you are saying that Expo does not support react-native-firebase? That means we will not add this support, because this is the only library we can use for RN

gwbischof commented 2 years ago

I think that expo supports react-native-firebase https://docs.expo.dev/guides/setup-native-firebase/#bare-workflow-setup

demchenkoalex commented 2 years ago

It should work in a bare workflow anyway? The question was about managed workflow I suppose. To do that I will need to rewrite everything using JS SDK.

hirbod commented 2 years ago

It also works now with the managed workflow using custom dev clients and expo config plugins.

lalitdhimaney commented 1 year ago

It also works now with the managed workflow using custom dev clients and expo config plugins.

Hi, @hirbod I am using expo managed workflow and was trying to implement Firebase messaging but getting the same error "Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.app()." Can you please let me know what specific steps you took while implementing? Link: https://rnfirebase.io/messaging/notifications Expo SDK: 47, React Native: 0.70.8, react-native-firebase/app: 18.1.0, react-native-firebase/messaging: 18.1.0

Noothan-am commented 1 year ago

hey @KMNowak, did you get any solution to fix it ?

KMNowak commented 1 year ago

hey @KMNowak, did you get any solution to fix it ?

Unfortunately not, I was applying that to PoCs I was building and gave this specific one up. Anyway, I hope someone will find a solution, so you will get unstuck.

cryptodev6 commented 9 months ago

Has anyone fixed it? I keep having the same trouble for a long time

demchenkoalex commented 9 months ago

please don't use this package @cryptodev6 - not maintained for a very long time. Just keeping it as a placeholder in case I will be able to return to it.