我实施了网络推送通知。获取错误的步骤:
我知道当服务工作者收到推送并且没有显示通知时会发生这种情况。但我看到正常的通知,为什么我也看到其他奇怪的通知?我可以摆脱这种行为吗?
答案 0 :(得分:5)
self.addEventListener('push', function(event) {
event.waitUntil(
self.registration.pushManager.getSubscription()
.then(function(subscription) {
fetch('url')
.then(function(response) {
self.registration.showNotification('title', {});
});
});
);
}
就我而言:
self.addEventListener('push', function(event) {
event.waitUntil(
self.registration.pushManager.getSubscription()
.then(function(subscription) {
return fetch('url')
.then(function(response) {
return self.registration.showNotification('title', {});
});
});
);
}
应该是:
<?php
try {
$dbh = new PDO("mysql:host=localhost;dbname=vbl", "root", "");
} catch (PDOException $e) {
echo $e->getMessage();
exit();
}
$query = "SELECT * FROM `users` WHERE LOWER(`username`) = :username";
$stmt = $dbh->prepare($query);
$stmt->bindValue(':username', strtolower($_POST['username']));
$stmt->execute();
if ($stmt->rowCount() == 1) {
$row = $stmt->fetch(PDO::FETCH_ASSOC);
require('blowfish.class.php');
$bcrypt = new Bcrypt(4);
if ($bcrypt->verify($_POST['password'], $row['password'])) {
header("location: cpanel.php");
} else {
header("location: login.php");
}
}
?>