I read the documentation and tried to implement in HTML page but it did not work.
I created the FCM project and select the cloud messaging and select the web part. They provided the following file:
<script src="https://www.gstatic.com/firebasejs/4.1.2/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "BIzaSyCODqtGdk9xNYU4ifeWiUvnRyrWA_N6np0",
authDomain: "checking-22492.firebaseapp.com",
databaseURL: "https://testings-22492.firebaseio.com",
projectId: "checking-22492",
storageBucket: "checkingwebdemo-22492.appspot.com",
messagingSenderId: "648493233490"
};
firebase.initializeApp(config);
</script>
I have already integrated it into iOS and Android, Please suggest how it will work in the web application.
Related
I am trying to build an flutter app purely as a website then should i use firebase initialize app twice both in index.html and main.dart?
index.html
<script>
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
var firebaseConfig = {
apiKey: "AIz...",
authDomain: "...",
databaseURL: "https://<project-name>.firebaseio.com",
projectId: "...",
storageBucket: "<project-name>.appspot.com",
messagingSenderId: "...",
appId: "...",
measurementId: "..."
};
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
Main.dart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
As mentioned in the docs here you should initialize it on both places.
As mentioned in the docs they are working on a way to initialize it just on one place:
We are actively investigating ways to initialize Firebase without directly using the CDN and will update the documentation once this becomes available.
in retool how to connect and upload the data in firebase using retool ,if any one help me out.
<script>
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
var firebaseConfig = {
apiKey: "AIzaSyC0W4G9vFxKV99kYDPvw_qgoMOF6Yj720g",
authDomain: "test-b0e28.firebaseapp.com",
databaseURL: "https://test-b0e28-default-rtdb.firebaseio.com",
projectId: "test-b0e28",
storageBucket: "test-b0e28.appspot.com",
messagingSenderId: "729064532529",
appId: "1:729064532529:web:ab1263c616218ebb990310",
measurementId: "G-Y64XEPGK2V"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
Retool has a native integration with Firebase, so you use their GUI for querying instead of writing in the SDK directly. Here's an example of what it looks like to query Firestore:
To connect a data source, you go to yoursubdomain.retool.com/resources/new and then find Firebase.
I want to collect the data of desktop app built with electron
I created the property(app+web) in firebase console then get the Firebase SDK snippet as below:
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.9.0/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/7.9.0/firebase-analytics.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "xxxxxxxxx",
authDomain: "xxxxxxx.firebaseapp.com",
databaseURL: "xxxxxxxxx",
projectId: "xxxxxxx",
storageBucket: "xxxxxxxxx",
messagingSenderId: "xxxxxx",
appId: "xxxxxxxxx",
measurementId: "G-xxxxxxxx"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
put the configuration into the body section then try to send the logEvent
unfortunately i cannot see any stream data in real-time data collection
Any thought would be appricated.
I am in the middle of making a quick web app and set up a client-side firebase connection. Following the docs, I added the below code to my index.html before any other scripts are loaded in my head. However, whenever I try to get any kind of information from the database, I get the following error: #firebase/database: FIREBASE WARNING: Firebase error. Please ensure that you spelled the name of your Firebase correctly (...)
I've tried following the docs about setting up a web app again, and copied the full config info. However, I keep getting the same error. I've checked that my database name is correct in the Firebase console.
<script src="https://www.gstatic.com/firebasejs/5.8.2/firebase-app.js"</script>
<script src="https://www.gstatic.com/firebasejs/5.8.2/firebase-database.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "...",
authDomain: "...",
databaseURL: "...",
projectId: "...",
storageBucket: "...",
messagingSenderId: "..."
};
firebase.initializeApp(config);
</script>
I appreciate your time and suggestions.
Ensure you have typed correctly with extension:
<script src="https://www.gstatic.com/firebasejs/5.8.2/firebase.js"></script>
<script>
// Initialize Firebase
// TODO: Replace with your project's customized code snippet
var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
projectId: "<PROJECT_ID>",
storageBucket: "<BUCKET>.appspot.com",
messagingSenderId: "<SENDER_ID>",
};
firebase.initializeApp(config);
</script>
I am able to trigger the push notifications, but i get this site has been updated in the background instead of the actual message.
The service worker code :
importScripts('https://www.gstatic.com/firebasejs/3.7.1/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/3.7.1/firebase-messaging.js');
// Initialize Firebase
var config = {
apiKey: "**************",
authDomain: "push-notifications-240e1.firebaseapp.com",
databaseURL: "https://push-notifications-240e1.firebaseio.com",
projectId: "push-notifications-240e1",
storageBucket: "push-notifications-240e1.appspot.com",
messagingSenderId: "********"
};
firebase.initializeApp(config);
i have fixed the issue, The service worker file had been cached. I will close this question now. I fixed it by adding the file in cache control.