1
すべてのWebブラウザとモバイルブラウザでHTML5プッシュ通知が機能しなくなりました。現時点では、私は次のコードを持っている:私は試してみて、Chromeを使用して、私のアンドロイド携帯電話上でコードを使用する場合すべてのWebブラウザとモバイルブラウザでHTML5プッシュ通知が機能するようにするにはどうすればよいですか?
<html>
<head>
<script>
document.addEventListener('DOMContentLoaded', function() {
if (Notification.permission !== "granted")
Notification.requestPermission();
});
function notifyMe() {
if (!Notification) {
alert('Desktop notifications not available in your browser.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
else {
var notification = new Notification('Notification title', {
icon: 'https://www.google.co.uk/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png',
body: "Hey there! You've been notified!",
});
notification.onclick = function() {
window.open("https://www.google.com");
};
}
}
</script>
</head>
<body>
<a href="javascript://" onclick="setTimeout(function(){ notifyMe(); }, 1500);" style="font-size:50px;background:#000;color:#fff;">Test nofitications (Will load in 1.5 seconds)</a>
</body>
</html>
、それは許可を求めたが、実際の通知が動作しません。
アイデア?
編集:
はありません成功し、次の試してみました:
http://www.girliemac.com/html5-notifications-webOS-style/
http://elfoxero.github.io/html5notifications/
http://codepen.io/imprakash/pen/ZYLayY
https://www.daftlogic.com/sandbox-using-html5-notifications.htm
https://davidwalsh.name/demo/notifications-api.php
http://ttsvetko.github.io/HTML5-Desktop-Notifications/
http://jsfiddle.net/Semmel/kY3Cq/
https://gauntface.github.io/simple-push-demo/
https://github.com/alexgibson/notify.js/blob/master/example/index.html
あなたが試すことができますChrome dev Toolsを使用してデスクトップから携帯電話の動作をデバッグし、 'console'でエラーが発生していないかどうかを確認することができます。 –