1

I have the following code, I add a new notification with one button... but actually, I see two buttons one that I have added and the second one "settings" when I clicked on the "settings" button nothing happened.

chrome.notifications.create(`my-notification-${Date.now()}`, {
            iconUrl: "assets/images/1.png",
            imageUrl: "assets/images/1.png",
            type: "image",
            contextMessage: "ddsdsd",
            message: request.options.message,
            title: "titletitle",
            buttons: [{
                title: "Yes"
            }]
        }, function(context) {
           console.log("Last error:", chrome.runtime.lastError);

            alert(JSON.stringify(chrome.runtime.lastError));
        }); 

BTW its not working with the following:

chrome.notifications.onButtonClicked.addListener(function (notifId, btnIdx) {

  if (btnIdx === 0) {
            alert('yes');
        } else if (btnIdx === 1) {
            alert('no');

        } else if (btnIdx === 2) {
            alert('12no');
        }
    });

not working also:

chrome.notifications.onShowSettings.addListener(  () =>  {
          alert('settings');
        })

enter image description here

Ortal Blumenfeld Lagziel
  • 2,415
  • 3
  • 23
  • 33
  • Open devtools for your background script and see if there are errors. Note that in ManifestV3 `alert` doesn't work in the service worker script. – wOxxOm Apr 21 '21 at 13:41
  • No errors!!!! and the alert is only for testing... – Ortal Blumenfeld Lagziel Apr 21 '21 at 14:22
  • This is some kind of chrome/chromium bug. ridiculous.. :/ https://stackoverflow.com/questions/64679280/chrome-extension-notifications-settings-button-is-not-working – rlf89 Feb 05 '23 at 09:50

0 Answers0