Dynamic links react uses module that is not installed

305 views Asked by At

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}>
   ...
   );
}
...
1

There are 1 answers

3
DIGI Byte On

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