[英]Send push notification on web app after a user submits a form
我们有一个在ASP.Net Web窗体上运行的Web应用程序。 用户转到要求某些信息的登录页面,并将其存储在SQL数据表中,并触发并将电子邮件通知到联系中心。
我们需要,当某些用户对表格进行汇总时,联络中心代理会从浏览器接收推送通知。
登陆页面位于特定的URL,例如www.mysite.com/landing.aspx,而联系中心的前端位于www.mysite.com/admin
到目前为止,我们已经尝试使用javascript。 我们有一个代码每分钟在数据库上搜索一次新记录,但是它使服务器工作量很大!
这是执行一分钟任务后加载的javascript:
window.onload = 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("New form request received!");
}
// Otherwise, we need to ask the user for permission
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
// If the user accepts, let's create a notification
if (permission === "granted") {
var notification = new Notification("New form request received!");
}
});
}
// At last, if the user has denied notifications, and you
// want to be respectful there is no need to bother them any more.
}
</script>
您知道实现此目标的更好方法吗? 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.