web-push-libs / web-push

Web Push library for Node.js
Other
3.28k stars 304 forks source link

Can webpush push be configured with images like new notification messages? #879

Closed yangfan-coder closed 10 months ago

yangfan-coder commented 10 months ago

When I was testing locally, I found that only the title and body can be configured in web push. Can we configure multiple properties for image and link like in new notification

web-push.js

 const payload = JSON.stringify({
    title: "I am a test message",
    body: "I am testing the text",
    // icon:"11.jpeg", //  How to configure it?
  });
  webpush.sendNotification(subscription, payload).catch(console.log);

new Notification

const options = {
      body: "I am testing the text",
      icon:"11.jpeg",
      data: {
        url: "https://example.com/review/12345",
        status: "open",
      },
    };
 const notification = new Notification("I am a test message",options);
marco-c commented 10 months ago

You can pass whatever you want as a payload.