1

While trying to create a dynamicLink, this error pops up:

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

  1. imported the 'io.invertase.firebase.app.ReactNativeFirebaseAppPackage' module in your 'MainApplication.java' file.

  2. Added the 'new ReactNativeFirebaseAppPackage()' line inside of the RN 'getPackages()' method list.

See http://invertase.link/android for full setup instructions.

I tried installing, importing and configuring @react-native-firebase/dynamic-links, react-redux-firebase, @firebase/app, firebase/app.

Currently react-redux-firebase is working, I can retrieve and send data to the firebase database. Is there any way I can use the firebase from this module to add dynamic links? Right now, I try to create a link like this:

import dynamicLinks from "@react-native-firebase/dynamic-links";

export class Baklijst extends Component {
    onAddPerson = async () => {
        const link = dynamicLinks().buildLink({
            link: "https://tomgroot.nl",
            domainUriPrefix: "https://baklijst.page.link",
        });
        console.log(link);
        return link;
    };

I initialise react-redux-firebase like this in my App.js:

if (!firebase.apps.length) {
    firebase.initializeApp(FirebaseConfig);
} else {
    firebase.app();
}

...

const rrfProps = {
    firebase,
    config: rrfConfig,
    dispatch: store.dispatch,
};

...
export default function App() {
   return (
   ...
       <ReactReduxFirebaseProvider {...rrfProps}>
   ...
   );
}
...
DIGI Byte
  • 4,225
  • 1
  • 12
  • 20
Tom Groot
  • 1,160
  • 1
  • 9
  • 26

1 Answers1

0

According to the documentation, to reference your react-native-firebase app with the following.

import firebase from '@react-native-firebase/app';

Additional modules should be imported as such

import '@react-native-firebase/dynamic-links';
// or
import dynamicLinks from '@react-native-firebase/dynamic-links';

To create dynamic links, you can copy the example from the documentation:

import dynamicLinks from '@react-native-firebase/dynamic-links';

async function buildLink() {
  const link = await dynamicLinks().buildLink({
    link: 'https://invertase.io',
    // domainUriPrefix is created in your Firebase console
    domainUriPrefix: 'https://xyz.page.link',
    // optional setup which updates Firebase analytics campaign
    // "banner". This also needs setting up before hand
    analytics: {
      campaign: 'banner',
    },
  });

  return link;
}

Source: https://rnfirebase.io/dynamic-links/usage#create-a-link

DIGI Byte
  • 4,225
  • 1
  • 12
  • 20
  • Doing exactly this, with importing `@react-native-firebase/dynamic-links` and `@react-native-firebase/app` and calling buildLink(), gives me the same error: "You attempted to use a firebase module that's not installed on your Android project by calling firebase.app()". I also tried to call `firebase.dynamicLinks().buildLink...` without luck – Tom Groot May 27 '21 at 19:27
  • try uninstalling and re-installing the modules, it sounds like it didn't install correctly – DIGI Byte May 27 '21 at 23:41
  • @TomGroot did you ever fix this? – ksingh Oct 05 '22 at 14:42