我正在使用HTML5通知API在Chrome或Firefox中通知用户.在桌面浏览器上,它可以工作.但是,在Chrome 42 for Android中,请求了权限,但未显示通知本身.
请求代码适用于所有设备:
if ('Notification' in window) {
Notification.requestPermission();
}
Run Code Online (Sandbox Code Playgroud)
发送代码适用于桌面浏览器,但不适用于移动设备:
if ('Notification' in window) {
new Notification('Notify you');
}
Run Code Online (Sandbox Code Playgroud) javascript html5 notifications google-chrome web-notifications
我的Web应用程序使用Notification API.
我认为KitKat的Chrome浏览器应该拥有它,或者至少是旧的webkitNotifications.但两者window.Notification并window.webkitNotifications都undefined在我的Chrome测试的Android 4.4系统.
在Android 4.4中看不到浏览器时,有没有办法将通知从浏览器推送到用户?或者我是否仍然需要在Android应用程序中嵌入我的Web应用程序才能实现此目的?当然,我对HTML5 Notification API以外的其他解决方案持开放态度,只要它们对我的用户来说是实用的(没有闪存).或者基于可靠的基于webkit的Chrome替代方案并具有通知API.