Skip to content

Releases: web-push-libs/web-push-php

v6.0.0

02 Aug 10:27
50e38b9
Compare
Choose a tag to compare
  • [Breaking Change] New API : sendOneNotification and queueNotification (see Usage in README)
  • [Breaking Change] PHP 7.2+ is now required
  • Upgrade web-token dependency (thx @baer95!)
  • Remove deprecated GCM auth support (thx @BR0kEN-!)

v5.2.5

02 Aug 09:29
Compare
Choose a tag to compare
  • Added SubscriptionInterface (thx @BR0kEN-!)

v5.2.4

23 Mar 17:19
Compare
Choose a tag to compare
  • Encode VAPID key in URL-safe base64 (thx @vockalimo!)

v5.2.3

25 Feb 18:44
Compare
Choose a tag to compare
  • Removed var_dump that could be triggered in case of encryption error (thx @zmotso!)

v5.2.2

23 Feb 19:39
Compare
Choose a tag to compare
  • Don't include VAPID headers if there are no content encoding in the subscription

v5.2.1

23 Feb 17:17
851faf0
Compare
Choose a tag to compare
  • FCM now supports AES128GCM on fcm/send endpoints, so the endpoint is no longer replaced with wp

v5.2.0

23 Feb 16:27
7150ba0
Compare
Choose a tag to compare
  • added ability to cache VAPID headers in a request (thx @javiermarinros!)
  • enhanced message reporting (thx @t1gor!)
  • made flush really async (thx @marcvdm!)
  • fixed an encryption error that would occur when using the new subscription structure with a contentEncoding (thx @soerenuhrbach!)
  • fixed an error that would occur if network request failed (thx @steffenweber!)
  • fixed some static errors

v5.1.0

29 Nov 08:45
Compare
Choose a tag to compare
  • Allow client subscription structure to be directly passed to create (thx @maglnet!)

v5.0.0

27 Nov 18:58
Compare
Choose a tag to compare

Breaking changes

You now need to iterate over the results of flush in order to actually send the notifications.

The way you handle the results of the flush() method should be changed. In v5 the flush always returns a Generator object. This means that you can still iterate over it, but you wouldn't be able to store it, at least not as-is. Using the example from the docs, the responses would now look different:

PLEASE NOTE:
\Generator is returned even if you only send one message.

BEFORE:

$res = [
    [ // first notification (failed)
        'success' => false,
        'endpoint' => $theEndpointToDeleteInYourDatabaseIfExpired,
        'message' => $responseMessage,
        'statusCode' => $responseStatusCode,
        'headers' => $responseHeaders,
        'content' => $responseContent, // you may have more infos here
        'expired' => $isTheEndpointWrongOrExpired,
    ],
    [ // second notification (succeeded)
        'success' => true,
    ],
    [ // third notification
        ...
    ], ...
];

AFTER:

var_dump($res); // \Generator

/** \Minishlink\WebPush\MessageSentReport */
foreach ($res as $result) {
    // you now have access to request & response objects

    /** @var \Psr\Http\Message\RequestInterface $request */
    $request = $result-> getRequest();
    /** @var \Psr\Http\Message\ResponseInterface $response */
    $response = $result->getResponse();

    if ($result->isSuccess()) {
        // process successful message sent
        $logger->log('Notification with payload %s successfully sent for endpoint %s.' [
            json_decode((string) $response->getBody()),
            $result->getEndpoint()
        ]);
    } else {
        // or a failed one - check expiration first
        if ($result->isSubscriptionExpired()) {
            // this is just an example code, not included in library!
            $db->markExpired($result->getEndpoint());
        } else {
            // process faulty message
            $logger->log('Notification failed: %s. Payload: %s, endpoint: %s' [
                $result->getReason(),
                json_decode((string) $response->getBody()),
                $result->getEndpoint()
            ]);
        }
    }
}

v4.0.2

13 May 15:00
5c2d2a5
Compare
Choose a tag to compare
  • Fix Subscription::create when not giving every keys