Chrome在Android上的通知显示在哪里?

17

请考虑以下内容。

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');
}

JSFiddle

在桌面版Chrome中,这似乎表现正常。在安卓Firefox中,此类通知会显示在安卓通知栏中。

然而,在安卓Chrome上,它似乎会提示用户允许/拒绝通知,但如果用户点击“允许”,似乎没有任何反应。安卓Chrome是否支持此类通知?

编辑:这与18个月前的这个问题不同-那时window.Notification根本没有定义。现在已定义,但似乎没有任何作用。


1
可能是Android Chrome浏览器中的通知API的重复问题。 - Pawel Uchida-Psztyc
1
@PawełPsztyć做出了相应的编辑。 - George Simms
1
@RalphWiggum 包含了一个 jsfiddle。 - George Simms
1
@RalphWiggum 设置 > 网站设置 > 通知是“先询问”,在我首次确认后允许 JSFiddle。当然,使用隐身模式每次都会提示。 - George Simms
1
我认为这个问题与以下问题重复:HTML5通知在移动Chrome中无法工作。当我在我的Android设备上进行调试时,我收到以下错误:Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification() instead. - Swimburger
显示剩余7条评论
3个回答

2

我认为这个问题与以下问题重复:HTML5 Notification在移动版Chrome中不起作用。 当我在我的Android设备上进行调试时,我会得到以下错误:

无法构造“Notification”:非法构造函数。请使用ServiceWorkerRegistration.showNotification()


0

应该使用servicework来显示通知:

            navigator.serviceWorker.register("some-empty.js");
            Notification.requestPermission(function (result) {
                if (result === 'granted') {
                    navigator.serviceWorker.ready.then(function (registration) {
                        registration.showNotification('Notification with ServiceWorker');
                    });
                }
            });

-2

Android无法接收Chrome通知,这与桌面版Chrome不同。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接