@@ -263,7 +263,7 @@ private function prepare(array $notifications): array
263
263
}
264
264
}
265
265
// if VAPID (GCM doesn't support it but FCM does)
266
- elseif (array_key_exists ('VAPID ' , $ auth )) {
266
+ elseif (array_key_exists ('VAPID ' , $ auth ) && $ contentEncoding ) {
267
267
$ audience = parse_url ($ endpoint , PHP_URL_SCHEME ).':// ' .parse_url ($ endpoint , PHP_URL_HOST );
268
268
if (!parse_url ($ audience )) {
269
269
throw new \ErrorException ('Audience " ' .$ audience .'"" could not be generated. ' );
@@ -373,12 +373,12 @@ public function countPendingNotifications(): int
373
373
374
374
/**
375
375
* @param string $audience
376
- * @param string|null $contentEncoding
376
+ * @param string $contentEncoding
377
377
* @param array $vapid
378
378
* @return array
379
379
* @throws \ErrorException
380
380
*/
381
- private function getVAPIDHeaders (string $ audience , ? string $ contentEncoding , array $ vapid )
381
+ private function getVAPIDHeaders (string $ audience , string $ contentEncoding , array $ vapid )
382
382
{
383
383
$ vapidHeaders = null ;
384
384
@@ -391,10 +391,6 @@ private function getVAPIDHeaders(string $audience, ?string $contentEncoding, arr
391
391
}
392
392
393
393
if (!$ vapidHeaders ) {
394
- if (!$ contentEncoding ) {
395
- throw new \ErrorException ('Subscription should have a content encoding ' );
396
- }
397
-
398
394
$ vapidHeaders = VAPID ::getVapidHeaders ($ audience , $ vapid ['subject ' ], $ vapid ['publicKey ' ], $ vapid ['privateKey ' ], $ contentEncoding );
399
395
}
400
396
0 commit comments