I am new in Flutter and i'm try to build aplication working with the database. In app I would for the user to add their own firebase database to working with with app. This is possible to add firebase database after build the app? Please information about this.
Thanks for any sugestions
You can specify the configuration data for the Firebase project in your Dart code as shown in this example in the FlutterFire docs:
FirebaseOptions get firebaseOptions => const FirebaseOptions(
appId: '1:448618578101:ios:0b650370bb29e29cac3efc',
apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0',
projectId: 'react-native-firebase-testing',
messagingSenderId: '448618578101',
);
Future<void> initializeDefault() async {
FirebaseApp app = await Firebase.initializeApp(
options: DefaultFirebaseConfig.platformOptions,
);
print('Initialized default app $app');
This means you can get the necessary data from the user or in another way at runtime, and only then initialize the app.
If you don't want to request the user to enter these details manually, you can use the REST API for managing projects to get a list of the user's projects. There is no Flutter/Dart wrapper for this API that I know off, so you'll have to write that yourself.
Related
I am currently building react application with firebase, i don't recall which location i setup for firestore but according to latest docs of firebase you could change location of firebase realtime database which i am unable to change from their website. Console log:-
#firebase/database: FIREBASE WARNING: Database lives in a different region. Please change your database URL to https://xxxxx-xxxx-default-rtdb.asia-southeast1.firebasedatabase.app (https://xxxxx-xxxx-default-rtdb.firebaseio.com/)
So, whenever i change url on the site and click go nothing works.
Try to set databaseUrl when you initialize the app.
firebase.initializeApp({
apiKey: 'key',
authDomain: 'domain',
projectId: 'id',
storageBucket: 'storage',
messagingSenderId: 'id',
appId: 'id',
databaseURL: 'paste-here-needed-database-url'
});
You can't change a location of a existing database. You would need to migrate it manually to a new one that you setup to the location you want. The migration is very easy. Just export the old database into a json file and import it to the new one. You can read more about it here.
There is no option to change the location of the firebase real-time database.
But there is a way to migrate,
You could create a new instance for the same project. Then you have to select the location that you need when creating the real-time database. After that, you have to export the old database and import it to the new one.
I just started implementing push notifications in Expo - following the guides on expo.io. Hence, I created an Android app in my Firebase console and my app.json contains now a reference to the Google service file:
"android": {
"package": "------------",
"googleServicesFile": "./google-services.json",
"useNextNotificationsApi": true,
}
If I test this on a real android device (standalone app) I do not receive a valid token via this function:
token = (await Notifications.getExpoPushTokenAsync()).data;
Instead I get the following error:
Error: Encountered an exception while calling native method: Exception
occured while executing exported method getDevicePushTokenAsync on
module ExpoPushTokenManager: Please set your project ID. A valid
Firebase project ID is required to communicate with Firebase server
APIs: It identifies your project with Google."
I guess it has something to do with the way of my project setup. I also followed the Expo guides to setup firebase (e.g. for phone authentication) and hence created a web app in the Firebase console. In my application I initialize the Firebase web app with my web app configuration like this:
const FIREBASE_CONFIG: IFirebaseOptions = {
apiKey: '--------',
authDomain: --------.firebaseapp.com',
databaseURL: 'https://--------.firebaseio.com',
projectId: '--------',
storageBucket: '--------.appspot.com',
messagingSenderId: '--------',
appId: '--------',
measurementId: '',
trackingId: '',
};
firebase.initializeApp(FIREBASE_CONFIG);
The FIREBASE_CONFIG (for my Firebase Web App) as well as the google-services.json (for my Firebase Android App) have the correct project ID. Do I need to initialize the Firebase Android App somehow?
I am using Expo SDK 40.0.1.
What helped me: I deleted the old Firebase Android App, created a new one, downloaded the google-services.json file and built a new version of my app: It worked.
I cannot come up with an explanation why the first Firebase Android App was faulty because I did not make anything different than I did now.
Hopefully that will help some of you as well.
Hey I got this same issue with my react native project. Actually it was working fine but one day this error popped up so I checked the last working version of my files.
The actual issue was with the version of my google services in the gradle file.
Instead on 3.0.0, I have changed it to "classpath 'com.google.gms:google-services:4.3.8'".
I would like to get data from Firebase. I found some tutorials, but all is using Google Credential ServiceAccount to initialize firebase app. this's is tutorial that i found :
https://medium.com/techwasti/spring-boot-firebase-crud-b0afab27b26e , and else tutorial i found, almost like that too, is using ServiceAccount.
But the problem is i cannot get the ServiceAccount from this firebase because it's from third party. that's mean the owner of firebase don't want to give ServiceAccount.json to me, but they give me firebase config to me, like this :
const firebaseConfig = {
apiKey: "apkey",
authDomain: authdomain",
databaseURL: "databaseurl",
projectId: "projectid",
storageBucket: "storragebucket",
messagingSenderId: "messagesenderid",
appId: "appid",
measurementId: "measurementid"
};
So, how can i initialize this firebase using kotlin in my java springboot aplication?
i had try to find the solution, but not found anything,
I would be glad for any help.
If you want to initialize the Firebase Admin SDK, you will need a service account. There are no alternatives for this.
The config for the front end web app that you're showing here will not work at all. That config is only used for frontend apps that are acting as clients on behalf of the end user.
Taking my first steps with Firebase. Just a few pointers to documents explaining what is going on will help.
I have set up a new firebase web project and connected my dev environment with the firebase sdk. Now when I drop the email-password quickstart into the project it works. (after enabling email/password sign in.)
But wait: This quickstart html file does not contain any configuration that the firebase console tells me to paste:
var config = {
apiKey: "xxx",
authDomain: "xxx.xxx.com",
databaseURL: "https://xxx.xxx.com",
projectId: "xxxx",
storageBucket: "xxx.xxx.com",
messagingSenderId: "xxx"
};
Does the local firebase server add the configuration in the background? When and where do I have to add this configuration to web pages?
If you check line 35 of that quickstart, you'll find this magic include:
<script src="/__/firebase/init.js"></script>
This is an auto-generated file by Firebase Hosting, that contains precisely the code that initializes the connection to the Firebase backend services of your project.
If you'd like to learn more about it, read:
Easier configuration for Firebase on the web
SDK imports and automatic initialization
SDK auto-configuration
I want to write a mobile app using react native. And I want to use firebase because it saves me a lot of time. I used firebase before for my web app and it worked pretty well. Now that react native is actually a real native app, I am thinking if I can use firebase features for my app. For example, third-party authentication, deep link, etc. I know that even though all written in Javascript, react native is not web app at all. There are specifically several features I want to use. Google Auth, Cloud Messaging, and some Analytics features. Is there any way I can put them in my app as if I am writing my app in Swift or Java?
First of all you might need to add firebase under dependencies in package.json file
"dependencies": {
"firebase": "^3.9.0",
"react": "^16.0.0-alpha.6",
"react-native": "0.44.0",
},
After that Import firebase
import * as firebase from 'firebase';
Then do the usual firebase initialization
const config = {
apiKey: "xxxxxxxxxx-xxxxxxxxxxxxx",
authDomain: "xxxxxxxxxxx.firebaseapp.com",
databaseURL: "https://xxxxxxxxxx.firebaseio.com",
projectId: "xxxxxxxxxx",
storageBucket: "xxxxxxxxxx.appspot.com",
messagingSenderId: "xxxxxxxxxx"
};
const firebaseApp = firebase.initializeApp(config);
Now that have connected firebase to your react-native app, you can retrieve the contents from the database like this
firebaseApp.database().ref("xxxxxx").on('value', (snap) => {
console.log(snap.val());
});
The remaining can be easily figured out similarly
If you still need more help you can check out the following link : https://firebase.googleblog.com/2016/01/the-beginners-guide-to-react-native-and_84.html