Skip to content

Commit 70de046

Browse files
committed
payload is supported on PHP5.4+
1 parent 1831b8d commit 70de046

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
## Installation
88
`composer require minishlink/web-push`
99

10-
If you have a PHP version smaller than 5.5.9, you will not be able to send any payload.
11-
1210
## Usage
1311
WebPush can be used to send notifications to endpoints which server delivers web push notifications as described in
1412
the [Web Push protocol](https://tools.ietf.org/html/draft-thomson-webpush-protocol-00).
@@ -175,7 +173,7 @@ using the user public key and authentication secret that you can get by followin
175173
Internally, WebPush uses the [phpecc](https://github.com/phpecc/phpecc) Elliptic Curve Cryptography library to create
176174
local public and private keys and compute the shared secret.
177175
Then, if you have a PHP >= 7.1, WebPush uses `openssl` in order to encrypt the payload with the encryption key.
178-
Otherwise, it uses [Spomky-Labs/php-aes-gcm](https://github.com/Spomky-Labs/php-aes-gcm) if you have PHP < 7.1, which is slower.
176+
Otherwise, if you have PHP < 7.1, it uses [Spomky-Labs/php-aes-gcm](https://github.com/Spomky-Labs/php-aes-gcm), which is slower.
179177

180178
### How to solve "SSL certificate problem: unable to get local issuer certificate" ?
181179
Your installation lacks some certificates.

src/WebPush.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ class WebPush
4242
/** @var bool Automatic padding of payloads, if disabled, trade security for bandwidth */
4343
private $automaticPadding = true;
4444

45-
/** @var boolean */
46-
private $payloadEncryptionSupport;
47-
4845
/** @var boolean */
4946
private $nativePayloadEncryptionSupport;
5047

@@ -64,8 +61,7 @@ public function __construct(array $apiKeys = array(), $TTL = 2419200, $timeout =
6461
$client = isset($client) ? $client : new MultiCurl();
6562
$client->setTimeout($timeout);
6663
$this->browser = new Browser($client);
67-
68-
$this->payloadEncryptionSupport = version_compare(phpversion(), '5.5.9', '>=') && class_exists("\\Jose\\Util\\GCM");
64+
6965
$this->nativePayloadEncryptionSupport = version_compare(phpversion(), '7.1', '>=');
7066
}
7167

@@ -195,7 +191,7 @@ private function prepareAndSend(array $notifications, $serverType)
195191
$userPublicKey = $notification->getUserPublicKey();
196192
$userAuthToken = $notification->getUserAuthToken();
197193

198-
if (isset($payload) && isset($userPublicKey) && isset($userAuthToken) && ($this->payloadEncryptionSupport || $this->nativePayloadEncryptionSupport)) {
194+
if (isset($payload) && isset($userPublicKey) && isset($userAuthToken)) {
199195
$encrypted = Encryption::encrypt($payload, $userPublicKey, $userAuthToken, $this->nativePayloadEncryptionSupport);
200196

201197
$headers = array(

0 commit comments

Comments
 (0)