firebase / firebase/quickstart-js
Data object in push event is empty for Chrome Extension
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 3.7k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 6
Description
**Describe your environment**
Operating System version: macOS (11.5.2)
Browser version: Google Chrome (95.0.4638.69)
Firebase SDK version: 7.16.1
Firebase Product: messaging
**Describe the problem**
Trying to use Firebase Cloud Messaging in Chrome Extension. Was able to register firebase messaging service worker and retrieve the token from SDK, but push notifications doesn't work. Upon sending a test notification from Firebase Cloud Messaging, service worker code gets fired, but `setBackgroundMessageHandler` doesn't get executed since payload is empty.
Steps to reproduce:
Sample project you can find here: https://github.com/asagabandi/firebase-messaging-chrome-extension
Relevant Code:
Part of the code, where setBackgroundMessageHandler should be called:
```
messaging.setBackgroundMessageHandler((payload) => {
console.log('[firebase-sw.js] Received background message ', payload);
const notificationTitle = 'Firebase notification';
const notificationOptions = {
body: 'Test firebase notification',
icon: 'Sample logo'
};
return self.registration.showNotification(notificationTitle, notificationOptions);
});
```
Contributor guide
Assessment
This issue has not been assessed yet.