chrome extension - show notifications with buttons - Setting button is not working

220 views Asked by At

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

0

There are 0 answers