请考虑以下内容。
if (this.Notification) {
Notification.requestPermission(function(permission) {
if (permission === 'granted') {
return new Notification('hi this is a test');
} else {
return alert("Notifications not permitted");
}
});
} else {
alert('Notifications not supported');
}
在桌面版Chrome中,这似乎表现正常。在安卓Firefox中,此类通知会显示在安卓通知栏中。
然而,在安卓Chrome上,它似乎会提示用户允许/拒绝通知,但如果用户点击“允许”,似乎没有任何反应。安卓Chrome是否支持此类通知?
编辑:这与18个月前的这个问题不同-那时window.Notification
根本没有定义。现在已定义,但似乎没有任何作用。
Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification() instead.
- Swimburger