firebase / firebase/quickstart-js

Data object in push event is empty for Chrome Extension

Open
#627 0 comments 0 reactions 0 assignees View on GitHub
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);
});
```

Firebase error

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.