-
Notifications
You must be signed in to change notification settings - Fork 987
Closed
Labels
Description
Operating System
N/A
Environment (if applicable)
N/A
Firebase SDK Version
react firebase 10.14.0
Firebase SDK Product(s)
Messaging
Project Tooling
ReactJS with webpack
Detailed Problem Description
cannot show notification
Steps and code to reproduce issue
when message sent, I got payload in my console but not have notification popup
I log registration, it not have showNotification: https://imgur.com/5ECwl43
here is my sw.js
import { initializeApp } from "firebase/app";
import { getMessaging, onBackgroundMessage } from "firebase/messaging/sw";
export default function() {
const firebaseApp = initializeApp({
apiKey: process.env.FIREBASE_API_KEY,
authDomain: process.env.FIREBASE_AUTH_DOMAIN,
projectId: process.env.FIREBASE_PROJECT_ID,
storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.FIREBASE_SENDER_ID,
appId: process.env.FIREBASE_APP_ID,
measurementId: process.env.FIREBASE_MERCHANT_ID
});
const messaging = getMessaging(firebaseApp);
onBackgroundMessage(messaging, (payload) => {
console.log('Message received. ', payload);
const notificationTitle = 'Background Message Title';
const notificationOptions = {
body: 'Background Message body.',
icon: '/firebase-logo.png'
};
self.registration.showNotification(notificationTitle, notificationOptions);
});
}