如何重定向点击通知?



我实现了推送通知调用,但当我调用推送通知显示,但没有重定向到URL?

My push Code:

<script src="https://js.pusher.com/7.0/pusher.min.js"></script>
<script>
Pusher.logToConsole = true;
var pusher = new Pusher('85066e9308022d00ffa2', {
cluster: 'mt1'
});
var channel = pusher.subscribe('request');
channel.bind('VehicleRequest', function (data) {
location.reload();
shownotification();
});
</script>

My notification Code:

<script>
function shownotification() {
const notification = new Notification("New Request!", {
body: "Please Check New Request",
});
notification.onclick = function (event) {
event.preventDefault();
window.location.href = '{{ url("") }}';
}
}
</script>

window.location.href = '{{ url("") }};改为window.open(url,'_blank');

最新更新