最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Push notifications using jQuery JavaScriptany plugin - Stack Overflow

programmeradmin0浏览0评论

Push notifications using jQuery JavaScript/any plugin.

I have a service that will return data as follows:- 

Error_Id, Description, DateTime, Etc.

Need to display these fields and it should also contain two buttons i.e. Accept & Reject.

On click of accept/reject button should call another service.

Tried jQuery notifications, but it does not work like browser notifications apis. When browser is minimized it will all minimize.

Tried browser notifications but could not add two custom buttons.

Ref link:-

Also referring the below link it clearly mentions cannot add buttons:- Desktop Notification with HTML Markup ( code example )?

Any help shall be greatly appreciated. Thanks!

Push notifications using jQuery JavaScript/any plugin.

I have a service that will return data as follows:- 

Error_Id, Description, DateTime, Etc.

Need to display these fields and it should also contain two buttons i.e. Accept & Reject.

On click of accept/reject button should call another service.

Tried jQuery notifications, but it does not work like browser notifications apis. When browser is minimized it will all minimize.

Tried browser notifications but could not add two custom buttons.

Ref link:- https://web-push-book.gauntface./chapter-05/02-display-a-notification/#title-and-body-options

Also referring the below link it clearly mentions cannot add buttons:- Desktop Notification with HTML Markup ( code example )?

Any help shall be greatly appreciated. Thanks!

Share Improve this question edited Jan 10, 2020 at 11:08 Dev asked Jan 10, 2020 at 10:42 DevDev 4106 silver badges23 bronze badges 2
  • What you have tried, please show us the code which is not working – Amanjot Commented Jan 10, 2020 at 10:46
  • I've updated 2 links containing ref code and another stating cannot add buttons. – Dev Commented Jan 10, 2020 at 11:09
Add a ment  | 

1 Answer 1

Reset to default 4

Use Link for add push notification in web application.

function notifyMe() {
  // 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") {
    // If it's okay let's create a notification
    var notification = new Notification("Hi there!");
  }

  // Otherwise, we need to ask the user for permission
  else if (Notification.permission !== "denied") {
    Notification.requestPermission().then(function (permission) {
      // If the user accepts, let's create a notification
      if (permission === "granted") {
        var notification = new Notification("Hi there!");
      }
    });
  }

  // At last, if the user has denied notifications, and you 
  // want to be respectful there is no need to bother them any more.
}
发布评论

评论列表(0)

  1. 暂无评论