Javascript 按按钮重置chrome通知
我正在开发一个web应用程序 我使用的是chrome通知,一旦chrome请求权限就会打开。 一旦授予Notification.permission,按钮将切换为on 我想做的是关闭这个按钮,并且——因此——也切换dektop通知,或者至少重新提示通知警报 这是我的密码Javascript 按按钮重置chrome通知,javascript,html,google-chrome,notifications,Javascript,Html,Google Chrome,Notifications,我正在开发一个web应用程序 我使用的是chrome通知,一旦chrome请求权限就会打开。 一旦授予Notification.permission,按钮将切换为on 我想做的是关闭这个按钮,并且——因此——也切换dektop通知,或者至少重新提示通知警报 这是我的密码 $scope.desktopNotificationSettings=function(){ // If browser doesnt support notifications if (!("Notifica
$scope.desktopNotificationSettings=function(){
// If browser doesnt support notifications
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
// This is entered if permission is already there and button is triggered :: That means user wants to switch of desktop notifications
else if (Notification.permission === "granted") {
console.log("Entered granted");
Notification.requestPermission(function (permission){
if (('permission' in Notification)) {
console.log(permission);
Notification.permission = denied;
}
});
this.allowDesktopNotification = false;
return;
}
// This triggers a chrome alert to block or allow notifications
else if (Notification.permission !== 'denied') {
console.log("Entered denied");
Notification.requestPermission(function (permission){
if (!('permission' in Notification)) {
Notification.permission = permission;
}
});
}
}
现在,如果权限被拒绝,那么请求权限第一次就可以正常工作。
如果我点击按钮,它不会触发chrome中的权限警报
请帮忙。谢谢您在这里使用AngularJS吗?你应该把它添加到你的标签上。