DevSync / src /lib /firebase.js
KIRAN PRAKASH GAWANDE
Initial commit
f299146
Raw History Blame Contribute Delete
2 kB
// // src/lib/firebase.js
// import { initializeApp } from "firebase/app";
// import { getMessaging, getToken, onMessage } from "firebase/messaging";
// const firebaseConfig = {
// apiKey: "AIzaSyBa0K39cni8TYcNbjRtrz6INj50IsOJck8",
// authDomain: "namanz-digitec.firebaseapp.com",
// projectId: "namanz-digitec",
// storageBucket: "namanz-digitec.firebasestorage.app",
// messagingSenderId: "139524323779",
// appId: "1:139524323779:web:21746333d7ecd17a6fa576",
// measurementId: "G-0J4KFEGZQN"
// };
// const app = initializeApp(firebaseConfig);
// const messaging = typeof window !== "undefined" ? getMessaging(app) : null;
// export { messaging, getToken, onMessage };
// src/lib/firebase.js
import { initializeApp, getApps, getApp } from "firebase/app";
import { getMessaging, getToken, onMessage, isSupported } from "firebase/messaging";
// const firebaseConfig = {
// apiKey: "AIzaSyBa0K39cni8TYcNbjRtrz6INj50IsOJck8",
// authDomain: "namanz-digitec.firebaseapp.com",
// projectId: "namanz-digitec",
// storageBucket: "namanz-digitec.firebasestorage.app",
// messagingSenderId: "139524323779",
// appId: "1:139524323779:web:21746333d7ecd17a6fa576",
// measurementId: "G-0J4KFEGZQN"
// };
const firebaseConfig = {
apiKey: "AIzaSyBUgPOEjspbAKYsJViFfPW5nD8tVqnWj-w",
authDomain: "nextwebtech-2505e.firebaseapp.com",
projectId: "nextwebtech-2505e",
storageBucket: "nextwebtech-2505e.firebasestorage.app",
messagingSenderId: "592051901415",
appId: "1:592051901415:web:e2c49edd9e531bedce2342",
measurementId: "G-JQV7WGBQ3P"
};
const app = !getApps().length ? initializeApp(firebaseConfig) : getApp();
let messaging = null;
// ✅ Only initialize messaging in the browser and if supported
if (typeof window !== "undefined") {
isSupported().then((supported) => {
if (supported) {
messaging = getMessaging(app);
} else {
console.warn("Firebase Messaging is not supported in this browser.");
}
});
}
export { app, messaging, getToken, onMessage };