diff --git a/.gitignore b/.gitignore index fd3dbb5..2b4cca0 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,6 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +#keys +config.js diff --git a/app/firebaseConfig.js b/app/firebaseConfig.js index 1577b13..1c5f031 100644 --- a/app/firebaseConfig.js +++ b/app/firebaseConfig.js @@ -1,21 +1,9 @@ // Import the functions you need from the SDKs you need import { initializeApp } from "firebase/app"; -import { getAnalytics } from "firebase/analytics"; +// import { getAnalytics } from "firebase/analytics"; import { getMessaging } from "firebase/messaging"; -// TODO: Add SDKs for Firebase products that you want to use // https://firebase.google.com/docs/web/setup#available-libraries - -// Your web app's Firebase configuration -// For Firebase JS SDK v7.20.0 and later, measurementId is optional -const firebaseConfig = { - apiKey: "AIzaSyD2HV19HltxDAOEEePnTLUvtuLLu_QRacs", - authDomain: "my-app-5ba3e.firebaseapp.com", - projectId: "my-app-5ba3e", - storageBucket: "my-app-5ba3e.appspot.com", - messagingSenderId: "419201348623", - appId: "1:419201348623:web:206cf5bd874fa5609edf7a", - measurementId: "G-L0E257E7X9" -}; +import { firebaseConfig, vapidKey } from '../my-app/config'; // Initialize Firebase const app = initializeApp(firebaseConfig); diff --git a/components/sendNotification.js b/components/sendNotification.js new file mode 100644 index 0000000..8195b59 --- /dev/null +++ b/components/sendNotification.js @@ -0,0 +1,4 @@ +import { Message } from "firebase-admin/messaging"; +import { NextRequest, NextResponse } from "next/server"; + +//notification send function here \ No newline at end of file diff --git a/public/firebase-messaging-sw.js b/public/firebase-messaging-sw.js index dd8a65b..d292ec9 100644 --- a/public/firebase-messaging-sw.js +++ b/public/firebase-messaging-sw.js @@ -1,3 +1,5 @@ +import { firebaseConfig, vapidKey } from '../my-app/config'; + // Import and configure the Firebase SDK // These scripts are made available when the app is served or deployed on Firebase Hosting // If you do not serve/host your project using Firebase Hosting see https://firebase.google.com/docs/web/setup @@ -5,45 +7,6 @@ importScripts('/__/firebase/9.2.0/firebase-app-compat.js'); importScripts('/__/firebase/9.2.0/firebase-messaging-compat.js'); importScripts('/__/firebase/init.js'); -/** - * Here is is the code snippet to initialize Firebase Messaging in the Service - * Worker when your app is not hosted on Firebase Hosting. - - // Give the service worker access to Firebase Messaging. - // Note that you can only use Firebase Messaging here. Other Firebase libraries - // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-app-compat.js'); - importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging-compat.js'); - - // Initialize the Firebase app in the service worker by passing in - // your app's Firebase config object. - // https://firebase.google.com/docs/web/setup#config-object - firebase.initializeApp({ - apiKey: 'api-key', - authDomain: 'project-id.firebaseapp.com', - databaseURL: 'https://project-id.firebaseio.com', - projectId: 'project-id', - storageBucket: 'project-id.appspot.com', - messagingSenderId: 'sender-id', - appId: 'app-id', - measurementId: 'G-measurement-id', - }); - - // Retrieve an instance of Firebase Messaging so that it can handle background - // messages. - const messaging = firebase.messaging(); - **/ - - const firebaseConfig = { - apiKey: "AIzaSyD2HV19HltxDAOEEePnTLUvtuLLu_QRacs", - authDomain: "my-app-5ba3e.firebaseapp.com", - projectId: "my-app-5ba3e", - storageBucket: "my-app-5ba3e.appspot.com", - messagingSenderId: "419201348623", - appId: "1:419201348623:web:206cf5bd874fa5609edf7a", - measurementId: "G-L0E257E7X9" - }; - firebase.initializeApp(firebaseConfig); const messaging = firebase.messaging();