-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
853500a
commit 59c9cda
Showing
3 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} | ||
"extends": ["next/babel","next/core-web-vitals"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Import the functions you need from the SDKs you need | ||
import { initializeApp } from "firebase/app"; | ||
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" | ||
}; | ||
|
||
// Initialize Firebase | ||
const app = initializeApp(firebaseConfig); | ||
const messaging = getMessaging(app); | ||
// const analytics = getAnalytics(app); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// 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 | ||
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(); | ||
|
||
messaging.onBackgroundMessage(function(payload) { | ||
console.log('[firebase-messaging-sw.js] Received background message ', payload); | ||
// Customize notification here | ||
const notificationTitle = payload.data.title; | ||
const notificationOptions = { | ||
body: 'Background Message body.', | ||
icon: '/firebase-logo.png' | ||
}; | ||
|
||
self.registration.showNotification(notificationTitle, | ||
notificationOptions); | ||
}); |