• Login
    • Search
    • Categories
    • Recent
    • Tags
    • Users
    • Groups
    • Rules
    • Help

    Do more on the web, with a fast and secure browser!

    Download Opera browser with:

    • built-in ad blocker
    • battery saver
    • free VPN
    Download Opera

    Opera notification not working

    General
    3
    7
    1831
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • kophaiem79
      kophaiem79 last edited by

      Opera 116.0.5366.71
      Windows 10 22H2 (0s build 19045.5371) Enterprise
      My extension can push notification to windows but when user click button it not working (older version Opera 99 and other browser like newest Chrome still work!). Seem chrome.notifications.onButtonClicked.addListener not working. i want to know if it was bug or find a way to stop using native notification only browser notification.

      Reply Quote 0
        1 Reply Last reply
      • burnout426
        burnout426 Volunteer last edited by

        Please provide a minimal demo extension to shows the issue.

        Reply Quote 0
          kophaiem79 1 Reply Last reply
        • Moved from Opera for Windows by  leocg leocg 
        • kophaiem79
          kophaiem79 @burnout426 last edited by leocg

          @burnout426

          File 1: notifier.js

          let url=window.location.href;
          if(url.indexOf('example.com')>-1){
          	document.addEventListener('click',()=>{
          		chrome.runtime.sendMessage(chrome.runtime.id,{data:'test'});
          	})
          }
          

          File 2:

          chrome.runtime.onMessage.addListener(data =>{
          	let m='notifier_id';
          	chrome.notifications.create(m, {title:'Demo title',message:'This is demo',type:'basic',requireInteraction:true,buttons: [{ title: 'Open' },{ title: 'Close' }]});
          	chrome.notifications.onButtonClicked.addListener(function(m,btnIdx){
          		if (btnIdx === 0) 
          		{
          			console.log('Open new tab');
          			chrome.tabs.create({ url: 'https://google.com' });
          			chrome.notifications.clear(m);
          			return false;
          		
          		} else if (btnIdx === 1){
          			chrome.notifications.clear(m);
          		}
          	});
          })
          

          File 3:

          {
            "name": "Notifier Demo",
            "version": "1.0.0.0",
            "manifest_version": 3,
          
            "description": "Notifier Demo",
            "content_scripts": [
              {
                "matches": ["https://www.example.com/"],
                "js": ["notifier.js"],
          	  "all_frames":true
              }
            ],
            "permissions": [
              "notifications","tabs"
            ],
            "background":{"service_worker":"background.js"}
          }
          
          

          How it work: go to https://www.example.com/, click anywhere will create a notifier. Click Open will open new tab google.com. Work on Edge, Chrome and old Opera browser. Not in my current version.

          Reply Quote 0
            burnout426 1 Reply Last reply
          • burnout426
            burnout426 Volunteer @kophaiem79 last edited by

            @kophaiem79 I get:

            Unchecked runtime.lastError: Some of the required 
            properties are missing: type, iconUrl, title and 
            message.
            Context
            Unknown
            Stack Trace
            :0 (anonymous function)
            

            when clicking on the example.com page (in Chrome too).

            Reply Quote 0
              kophaiem79 1 Reply Last reply
            • kophaiem79
              kophaiem79 @burnout426 last edited by

              @burnout426 icon128.png
              File: background.js
              chrome.runtime.onMessage.addListener(data =>{
              let m='notifier_id';
              chrome.notifications.create(m, {title:'Demo title',message:'This is demo',iconUrl: 'icon128.png',type:'basic',requireInteraction:true,buttons: [{ title: 'Open' },{ title: 'Close' }]});
              chrome.notifications.onButtonClicked.addListener(function(m,btnIdx){
              if (btnIdx === 0)
              {
              console.log('Open new tab');
              chrome.tabs.create({ url: 'https://google.com' });
              chrome.notifications.clear(m);
              return false;

              	} else if (btnIdx === 1){
              		chrome.notifications.clear(m);
              	}
              });
              

              })
              Save icon (name:icon128.png) in same folder.

              Reply Quote 0
                burnout426 1 Reply Last reply
              • burnout426
                burnout426 Volunteer @kophaiem79 last edited by

                @kophaiem79

                That fixed the extension. However, testing on Windows 11 23H2, clicking at https://www.example.com/ wasn't triggering a notification at all in Opera.

                However, I noticed that Opera wasn't listed in "Settings -> System -> Notifications" in Windows, so I went to https://cleverpush.com/en/test-notifications/, clicked "Greetings", chose "allow" and clicked "Greetings" again to show a notification in Opera and that added Opera to the notification settings in Windows.

                Then, I cleared notifications by clicking the clock in the Windows systray to bring up notifications and clicked "Clear".

                Then, I tried your extension in Opera again and clicking on the https://www.example.com/ page starting working and showing the notification. Clicking "open" on the notification doesn't do anything though. I don't think the ButtonClicked event is firing for some reason in Opera, just like you said. According to https://help.opera.com/en/extensions/apis/, Opera does have some limitations on the notifications API, but nothing specific to the firing of the event.

                I also deleted all entries from "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings" in the registry and restarted Opera. Even though Opera was no longer listed in the Windows notification settings, your notification popup was still showing up.

                So, there's definitely some quirkyness going on there. But yes, I can confirm the event listener issue in Opera. Sounds like a bug to me.

                Reply Quote 1
                  kophaiem79 1 Reply Last reply
                • kophaiem79
                  kophaiem79 @burnout426 last edited by

                  @burnout426
                  Thank for confirm it. We are back to version 99.0.4788.88.

                  Reply Quote 0
                    1 Reply Last reply
                  • First post
                    Last post

                  Computer browsers

                  • Opera for Windows
                  • Opera for Mac
                  • Opera for Linux
                  • Opera beta version
                  • Opera USB

                  Mobile browsers

                  • Opera for Android
                  • Opera Mini
                  • Opera Touch
                  • Opera for basic phones

                  • Add-ons
                  • Opera account
                  • Wallpapers
                  • Opera Ads

                  • Help & support
                  • Opera blogs
                  • Opera forums
                  • Dev.Opera

                  • Security
                  • Privacy
                  • Cookies Policy
                  • EULA
                  • Terms of Service

                  • About Opera
                  • Press info
                  • Jobs
                  • Investors
                  • Become a partner
                  • Contact us

                  Follow Opera

                  • Opera - Facebook
                  • Opera - Twitter
                  • Opera - YouTube
                  • Opera - LinkedIn
                  • Opera - Instagram

                  © Opera Software 1995-