Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // firebase-messaging-sw.js
- ....
- messaging.setBackgroundMessageHandler(function(payload) {
- console.log('[firebase-messaging-sw.js] Received background message ', payload);
- // Customize notification here
- let notificationTitle = 'Background Message Title';
- let notificationOptions = {
- body: 'Background Message body.',
- icon: 'resource/icon_web.png'
- };
- return self.registration.showNotification(notificationTitle, notificationOptions);
- });
- // popup.js
- firebase.initializeApp(config);
- const messaging = firebase.messaging();
- messaging.onMessage(function (payload) {
- console.log('Message received. ', payload);
- });
- [firebase-messaging-sw.js] Received background message
- {data: {…}, from: "153493200810", collapse_key: "do_not_collapse"}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement