Closed ziaratban closed 3 years ago
At first, I thought I had the same need as you. Then I remembered that the endpoint uniquely identifies a push subscription.
From the W3C Push API specification:
A push subscription has an associated push endpoint. It MUST be the absolute URL exposed by the push service where the application server can send push messages to. A push endpoint MUST uniquely identify the push subscription.
So, you can use the getEndpoint
method to retrieve the endpoint of the request and then use it as unique key:
foreach($webpush->flush() as $report) {
$endpoint = $report->getEndpoint();
//Check if the subscription is invalid or expired.
if($report->isSubscriptionExpired()) {
//Delete subscription from db using $endpoint as UK.
}
}
Hope this can help you!
Hello @ziaratban and @AndrewGalaz23 are you aware if it's possible that when one clicks on a notification if it's possible that it can open up the browser and go to a specific website and or section on that website?
Yes that's it!
While endpoint is good, I do think passing custom data would be helpful here, for example when you're sending multiple notifications to the same endpoint.
i want to use the batch feature for more performance. so i need set the key for each subscription and get that key in the result.
for example