How to Read data from 2 different Firebase database which are from 2 different projects - firebase

Basically i want to access two different databases form two different projects in firebase from one flutter app,
For more info ,
I have build a single Flutter app in which ,
some time i want to refer to one database of (Project name "A" ) and some time i need to refer another database of (Project name "B") ,
is there a way to refer to 2 different database at a time in single app.
Thanks in advance.

Yes, it is possible to read data from 2 different Firebase databases through a single app. Simply go to your Home page on your Firebase console and app your app (both iOS and Android, I assume, since you are developing with Flutter) for both databases.

Related

Move Firebase project to another region

I am using Firebase for a long time (since 2018) and loving it. In that time there was not Location southamerica-east1 (São Paulo). Now I would like to store the project (web app, cloud function, and database) in southamerica to reduce cost and make it near to my end-users (also based in Brazil).
I have source control, all environment parameters values stored in Custom Environment Variables. The application works fine when no data is found. No concerns with backup data. No problem about downtime. This is not a critical app.
Anyway, I can't delete the application because I already have some users logged in there and IoT devices sending data through PubSub.
How can I rebuild my Firebase/Firestore/Web application/Function from the ground up, and make sure the new location is southamerica? If possible, I need to keep user and passwords, and web
Looking forward, (I don't think moving the bucked location would be the best solution here) but based on this page Select locations for your project I can't update the location, but since it is based on bucked location, if it doesn't break the project, I will use Google Cloud Transfer Page to Moving and renaming buckets
May is it a better solution than rebuild the app (Firebase/Firestore/Web application/Function)?
May I break my Firestore database or cloud function or web app?
May I lost my project domain or any other related URL parameter like authDomain, databaseURL, storageBucket?
May I need to update some web app parameter after the change?
They cannot be moved at present and migrating data is a manual process. Difficulty varies by product.
General guidance
Do not delete the old project before fully migrated.
Hosting
This migration is nearly trivial, with the understanding that there is likely a minor service interruption while moving custom domains.
Deploy to the new site
CNAME your custom domain to the new site (myproject.firebaseapp.com)
Delete custom domain from old site
Add custom domain to new site
Cloud Functions
This migration is trivial.
Create a local directory for your new project
Run firebase init and set up project normally (enable Functions)
Copy your Functions code into the new project's functions/ directory
Deploy to the new project
Database
This migration is tricky, difficult, and highly specific to your use case and tolerance for downtime. What follows is a general template to adapt.
Reference docs for import/export: Firestore import/export, Realtime Database backups
In the old project:
Lock the database using security rules to prevent changes
Export existing database
In the new project:
Import the database backup
You probably need to migrate existing users (see account export/import) as well so user ids stored in your DB will still reference the correct accounts
Point existing apps to the new project
If downtime is not an option, or if you'll be deploying a new mobile app version and need time for changes to propagate, then you'll need to set up a dual write model:
Dual sync: Create a Cloud Function on both the new and old database that duplicate all create/update/delete operations on the respective partner endpoint.
Sync pre-existing data: Perform the export/import process as above on all data created before the dual sync was implemented, excluding the step to lock the old database
Shut down your old mobile app version (once enough accounts have migrated)
Shut down the dual sync Functions and turn down the old site
Based in your information, the main issue is Firestore because other products are globally balanced like Cloud IoT Core and Hosting (these can't be configured on a specific region)
Other products like Functions can be redeployed with the same code and name into another region.
I think that you can create another project only to move the database to the new region and configure all Cloud resources to reach the new located database.
As a caveat, you need to add another domain/subdomain and create new credentials to work with the new project; this step can´t be skipped because it is required for authentication.
On the application side you can add the access to the new database
In case you need assistance during your migration you can start a case with GCP/Firestore support.
This is a hard pill to swallow, but maybe the costs and the time to migrate to another region will be higher than keeping your application as is working today.

How do I create two apps with same firebase database in Flutter? [duplicate]

This question already has answers here:
Can multiple android application access same firebase database?
(8 answers)
Is there a way to have 1 Firebase database for 2 apps with different package names?
(1 answer)
Closed 2 years ago.
For my project I have to create 2 apps where 1 is for the customer(i.e. he can see all products) & the second is for the seller(i.e. he can see which customer has bought his products). I have already created a new firebase project. But how do I connect both the customer & seller app to the same firebase project in Flutter so that when the seller lists an item a customer can see it?
It's pretty easy to do so with firebase.
Go to Firebase console : https://console.firebase.google.com and open your project
Click on the Add App button, (as you normally would to add the first app).
Choose your platform android or ios.
Then follow the procedures on the screen, add your package name, SHA-keys (if you require oauth)
Download and save the firebase config file.
You can generate different config files for different apps in the same firebase project, and use them with different code sources.

Need to store a file/pdf in SQLite in Ionic 4

I’m new to ionic and in my Ionic Application, I need to store a pdf and image file in SQLite i.e in the app storage and should open within app. I will get the file from another database like MongoDB in the URL format. Could anyone of you help me out of this and suggest any references to complete the app storage using SQLite.
Thanks in advance.
I have researched on different aspects but could not find any.

Why does my deployment have no data but my preview has all the data?

My preview works and has data but my deployment has no data. I'm using the (Recommended) DEFAULT CLOUD SQL database configuration.
Note: This is only day 4 with Google App Maker. Finding answers to App Maker-specific questions has been super difficult, but I'm making rapid progress on my application, so overall tired but good. :{)
As written in the documentation,
App Maker deployments can use the same Cloud SQL instance, but have separate databases on that instance. Data that you had in preview mode is not available in other deployments. You have a few options for how to handle this situation:
To use data from the preview instance in your published deployment, export the deployment data from the preview instance and import it to the published deployment.
To share a database across all deployments (preview and published), use a custom Cloud SQL database.
When you deploy your app, AppMaker create a new database in your google cloud SQL instance for the deployment. All the data create in previews is in another database.
To use the same database as the preview mode you have to go in the settings of your app in the tab "DATABASE" and copy the Database Key. Then go to your cloud sql instance in google cloud platforme and on the details of the instance in the overview tab just copy the instance connexion name.
then edit your deployments and select "Use Custom Cloud SQL database" and copy with the format
"instanceConnexionName/DatabaseKey" then save and appmaker should ask you to enter you username and password of your google cloud sql insatnce.
On app settings, database page you should see
Databas key: iTIJQaCj491a4111
(Actually this is the name of the mySQL instance)
In GCP console, go to SQL, click on Instance ID, and on the Instance ID overview page is the instance connection name, e.g., MyProject-123456:us-central1:instancename
Back in app settings
Select Switch to custom database and enter the full connection string
projectname:instancename/schema as
MyProject-123456:us-central1:instancename/iTIJQaCj491a4111
Provide username and password
and follow the steps to confirm existing database
Turns out the issue is when you publish it doesn't push the data, you have to manually re-upload the data into the live version. This is actually a good thing, but I wish it'd been explicitly documented. I found it, after figuring it out on my own, in some early release notes from a few years back. I guess I wasn't the only one this stupid.

How to Differentiate Staging/Dev and Production Build for Android/IOS in Google Firebase for Analytic and Crash

Recently I have Added the my Android and iOS project to Firebase with alpha version.I want to See different Analytic and Crash for Staging and Production. Can anyone help on this.
Thanks
You have several options, depending upon what your needs are. The bottom line is that you should, at the very least, assign different application IDs to the different variants of your app, so they can be separate in the Firebase Console. You can have multiple apps per project (each assigned a different ID), or multiple projects with an app in each one, depending upon what works best for your team and your app.
The actual implementation can get complicated from here on out, so I suggest you read this blog post to learn about the options for your Android app, and how it affects the operation of the various Firebase features in that app.
I think of 2 ways to do so:
Using app version + date range: If you know your app in staging was version X from day N to N+10, you can select theses filter in Firebase analytics to display only the analytics coming from that configuration. This also work for crash reporting.
I prefer: Using a remote config & user property:
Setup in remote config a key as "environment" with some values like "alpha", "beta", "prod". You can then specify the value per platform/app version.
On the phone, read that value in remote config and track a user property in Firebase Analytics that reflect that value.
Finally in the Firebase console you can filter by user property (& app version if necessary).
With this option, when you move an app version out of alpha to beta (for instance) you just need to go in remote config, and change the value for that app version to "beta". This solution doesn't work for crash reporting.
You can use a different Firebase project for each stage so that the analytics are completely distinct. See more on that in the response to this question.
Create a user property Environment, give values such as Dev, Staging and Prod to it on build time.
Change the user property from client side to any of the above three mentioned values based on the build type.
Apply filter by Environment user property on firebase console to see the analytics data.

Resources