Chrome Android 上的通知显示在哪里?
Where do notifications show on Chrome on Android?
考虑以下因素。
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 桌面版中符合预期。在 Android 的 Firefox 中,此类通知出现在 Android 通知栏中。
但是在 Android Chrome 上它似乎提示用户 allow/disallow 通知,但是如果用户单击 'allow' 似乎什么也没有发生。 Android Chrome 支持这种通知吗?
编辑: 这与 this question from 18 months ago 不同 - 然后根本没有定义 window.Notification
。现在它被定义了,但似乎没有做任何事情。
我认为这与以下问题 重复。
当我在 Android 设备上调试它时,出现以下错误:
Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification()
Android 不接收 chrome 通知,不同于桌面 chrome
它应该使用服务工作来显示通知:
navigator.serviceWorker.register("some-empty.js");
Notification.requestPermission(function (result) {
if (result === 'granted') {
navigator.serviceWorker.ready.then(function (registration) {
registration.showNotification('Notification with ServiceWorker');
});
}
});
考虑以下因素。
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 桌面版中符合预期。在 Android 的 Firefox 中,此类通知出现在 Android 通知栏中。
但是在 Android Chrome 上它似乎提示用户 allow/disallow 通知,但是如果用户单击 'allow' 似乎什么也没有发生。 Android Chrome 支持这种通知吗?
编辑: 这与 this question from 18 months ago 不同 - 然后根本没有定义 window.Notification
。现在它被定义了,但似乎没有做任何事情。
我认为这与以下问题
Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification()
Android 不接收 chrome 通知,不同于桌面 chrome
它应该使用服务工作来显示通知:
navigator.serviceWorker.register("some-empty.js");
Notification.requestPermission(function (result) {
if (result === 'granted') {
navigator.serviceWorker.ready.then(function (registration) {
registration.showNotification('Notification with ServiceWorker');
});
}
});