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

Impossible to set icon via (Notification Composer)[GUI] #8636

Open
Mateostin opened this issue Nov 13, 2024 · 3 comments
Open

Impossible to set icon via (Notification Composer)[GUI] #8636

Mateostin opened this issue Nov 13, 2024 · 3 comments

Comments

@Mateostin
Copy link

Mateostin commented Nov 13, 2024

Operating System

Ubuntu 24.04

Environment (if applicable)

Chrome 129.0.6668.58

Firebase SDK Version

10.14.1

Firebase SDK Product(s)

Messaging

Project Tooling

JavaScript SDK libraries from the CDN

Detailed Problem Description

Is there any way to override the imported firebase-js-sdk configuration for displaying push notifications in a service worker that was send via "Notification Composer"? I know that when sending notifications (data messages) via the API, this is possible, and I can do it. However, my problem is that I would like to be able to send push notifications from the Notification Composer, but there, I can't set the "Icon", this is crucial for us. Is there any workaround, for example, writing code before importing and overriding the default function, similar to the situation when i do something like this for change the "click_action"

self.addEventListener('notificationclick', function(event) {
    // here my code for override the click_action URL
});

Why is it not possible to directly set the icon from the GUI? it's weird and unintuitive because it seems like a basic feature, just like setting the "image". Especially if we know that icon would be attached if we send notification by API (data message) and have this code in "firebase-messaging-sw.js":

messaging.onBackgroundMessage((payload) => {
    console.log(
        '[firebase-messaging-sw.js] Received background message ',
        payload
    );

    if (!payload.notification) {
        const notificationTitle = 'My title';
        const notificationOptions = {
            body: 'My body msg',
            image: 'url-to-my-image',
            icon: 'url-to-my-icon',
            badge: 'url-to-my-badge',
        };

        // Show the notification
        self.registration.showNotification(notificationTitle, notificationOptions);
    }
});

Why this parameters cannot be set in "Notification Composer" by using "Additional options" for example like this:
image

Steps and code to reproduce issue

Send push notification from Notification Composer

@Mateostin Mateostin added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Nov 13, 2024
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@jbalidiong jbalidiong added api: messaging needs-attention and removed needs-triage new A new issue that hasn't be categoirzed as question, bug or feature request labels Nov 13, 2024
@dlarocque
Copy link
Contributor

Hi @Mateostin, I am not sure if I fully understand the issue. I see in the reference documentation that if the icon is not present in the notification request, FCM will use the icon found in your apps manifest.
Are you requesting to be able to send icon from the Notification Composer in the Firebase Console? If so, please submit this to Firebase Support so that the Firebase Console team (not us) can see it.

As a temporary workaround, you could try adding an event listener on 'push' events, then try overriding the payload to set the icon. Alternatively, you could use patch-package to override the behaviour of the SDK in externalizePayload.ts. I have not tried either of these myself, so I am not certain whether they will solve your issue.

@google-oss-bot
Copy link
Contributor

Hey @Mateostin. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

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

No branches or pull requests

4 participants