相关疑难解决方法(0)

HTML5通知无法在移动Chrome中使用

我正在使用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

32
推荐指数
2
解决办法
3万
查看次数

Android上的Chrome上会显示通知的位置?

考虑以下.

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');
}
Run Code Online (Sandbox Code Playgroud)

JSFiddle.

这似乎与桌面版Chrome中的预期一致.在Firefox for Android中,此类通知会显示在Android通知栏中.

但是在Android Chrome上,它似乎会提示用户允许/禁止通知,但如果用户点击"允许"似乎没有任何结果.Android Chrome是否支持此类通知?

编辑:与18个月前的这个问题不同- 然后window.Notification根本没有定义.现在它被定义但似乎没有做任何事情.

javascript notifications android google-chrome

16
推荐指数
1
解决办法
1421
查看次数