$auth = array(
'VAPID' => array(
'subject' => 'web.example.com',
'publicKey' => 'BDASezNQ-*********',
'privateKey' => 'CqPxWr_*******'
//'pemFile' => './keys/private_key.pem' // if you have a PEM file and can link to it on your filesystem
),
);
$defaultOptions = array(
'TTL' => 300, // defaults to 4 weeks
'urgency' => 'normal', // protocol defaults to "normal"
'topic' => 'push', // not defined by default - collapse_key
);
$webPush = new WebPush($auth, $defaultOptions);
// send multiple notifications with payload
$webPush->flush();
// send one notification and flush directly
$webPush->sendNotification(
$notifications[0]['subscription'],
$notifications[0]['payload'], // optional (defaults null)
true // optional (defaults false)
);`
im getting this error and im not sure why.
Below is the code that i used :
`$sub_endpoint = $endpoint; $sub_publicKey = 'BDASezNQ-****'; $sub_authToken = $authToken; $sub_contentEncoding ='aesgcm'; $notifications = [ [ 'subscription' => Subscription::create([
'endpoint' => $sub_endpoint, 'publicKey' => $sub_publicKey,
'authToken' => $sub_authToken,
'contentEncoding' => $sub_contentEncoding, ]), 'payload' => '{msg:"test"}', ], ];