Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data object in push event is empty for Chrome Extension #627

Open
asagabandi opened this issue Nov 10, 2021 · 0 comments
Open

Data object in push event is empty for Chrome Extension #627

asagabandi opened this issue Nov 10, 2021 · 0 comments

Comments

@asagabandi
Copy link

asagabandi commented Nov 10, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant