vendredi 3 août 2018

Web API Notification requireInteraction is not working in Electron App for Windows

I am using Web API Notification in my electron app following this Documentation : Developer_Mozilla_Web_API_Notification

My code looks like this :

notifyMe() {
   var msg = "Notification Check!!!";
   var options = {
     body: '',
     requireInteraction: true,
     sticky: true
   }
   // Let's check if the browser supports notifications
   if (!("Notification" in window)) {
      alert("This browser does not support desktop notification");
   }

   // Let's check whether notification permissions have already been granted
   else if (Notification['permission'] === "granted") {
      var notification = new Notification(msg,options);
      notification.onclick = (event)=> {
        //some action
      };
   }

   // Otherwise, we need to ask the user for permission
   else if (Notification['permission'] !== "denied") {
      Notification.requestPermission((permission)=> {
        // If the user accepts, let's create a notification
        if (permission === "granted") {
           var notification = new Notification(msg,options);
           notification.onclick = (event)=> {
             //some action
           };
        }
     });
   }
}

After saving all the code, I made a build for Windows Platform using Electron Packager using command :

$ electron-packager . --platform=win32 --arch=ia32

Although, as per Mozilla Documentation, I have mentioned the

requireInteraction: true, sticky: true

However, both of these options are working fine in chrome browser but unfortunately these options are not working in the electron build app for windows.

The Notifications are showing but they do not wait for any user interaction and gone.

I do need an urgent reply or recommendation over this. If you have any other library in your knowledge for showing sticky notifications in windows platform which stick to the screen unless user perform any action, kindly suggest in comments.




Aucun commentaire:

Enregistrer un commentaire