我在Android版Chrome和标准版(51)上都遇到了问题。虽然通知api在其他浏览器(台式机上的Chrome和Firefox以及Android上的Firefox)上都可以完美运行,但不幸的是,它在移动chrome上无法正常运行。浏览器要求获得通知事件的权限,但不显示它。如上所述,同一部手机上的Firefox以及桌面版本的Chrome都没有问题。这是我的代码:
handleNotification: function (message) {
if (!Notification) { return; }
if (Notification.permission !== "granted") { Notification.requestPermission(); }
else {
var notification = new Notification(participantsRepository[message.senderID].firstName, {
icon: participantsRepository[message.senderID].photo,
body: message.body,
});
notification.onclick = function () {
this.props.updateViewOnMessengerComponent('threadView');
this.updateCurrentThread(message.thread, true);
}.bind(this);
}
},
任何想法如何解决?
干杯,Wojtek
我在Twitter上向Alex Russel询问了有关此问题的信息,结果发现,我的应用程序中使用的旧版通知API当前不受任何移动版本的chrome支持。看来我必须使用Google的官方推送通知API,尤其是针对Android用户。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句