数据库获取订阅了推送通知的用户,然后循环遍历所有用户,并使用我的应用程序密钥将通知发送到端点-正确
但是文件返回错误,提示缺少$ auth密钥
$auth = array(
'subject' => 'omitted',
'publicKey' => 'omitted',
'privateKey' => 'omitted'
);
$webPush = new WebPush($auth);
while($row = $subscriptions->fetch_assoc()){
$res = $webPush->sendNotification(
$subscription = Subscription::create([
'endpoint' => $row['endpoint'],
'publicKey' => $row['p256dh'],
'authToken'=> $row['auth'],
'contentEncoding' => 'aesgcm'
]),
$notification,
true
);
}
答案 0 :(得分:0)
您的$ auth数组应如下所示:
$auth = array(
'VAPID' => array(
'subject' => '',
'publicKey' => '',
'privateKey' => ''
),
);