Home > Mobile >  How do I manage 2 Firebase apps connecting to the same project
How do I manage 2 Firebase apps connecting to the same project

Time:09-27

I have 2 versions of a Firebase app, call them regular and pro, such that users of the regular app interact with those of the pro app, and thusly need access to the same Firestore database and same superset of Firebase cloud functions. The relationship is such that there are a set of cloud functions that the regular app would use exclusively, a set that the pro app would use exclusively and a set that both would use. The regular and pro apps are different enough to warrant separate projects, and thusly have separate git repositories. This is perfectly fine in most situations, but it still has the following problems:

  1. When I add a cloud function to the regular app, that same function will not automatically be updated in the pro app git repo. As you can imagine this will cause grief in maintaining a consistent store of cloud functions. I am fine having a superset of cloud functions that can be accessed by both projects, and managing access to them as normal, but I am not seeing a way to maintain this superset of cloud functions across both git repos. Furthermore, there are also foreseeable problems if I update the cloud functions from different repos in succession.
  2. This same principal applies to the Firestore rules as well. I need to maintain the same rules across both apps and am not sure the best way to do this.
  3. The former two problems get worse when other developers are added in the future and we have to maintain that consistent superset of cloud functions across the branches contributed by these new developers.

One other note: my app is built with Ionic 4.

Any suggestions with this are much appreciated.

CodePudding user response:

The regular and pro apps are different enough to warrant separate projects, and thusly have separate git repositories.

It honestly sounds like this choice is causing you problems, so I'd recommend reconsidering.

If both apps make calls against the same backend (Cloud Functions security rules) then the backend for both apps should be stored in a single place at least.

The apps themselves could be in separate repositories, but I'd probably just put them as subdirectories in the same rep as the backend too. For example in a top-level structure like this

app
  regular app files go here
pro
  pro app files go here
rules
  security rules go here
functions
  cloud functions code goes here
  • Related