bpolaszek / webpush-bundle

Symfony Bundle: Send WebPush Notifications to your users.
MIT License
66 stars 40 forks source link

Failures and delays on Apple endpoints #45

Open 121593 opened 11 months ago

121593 commented 11 months ago

I observed the process hanging on for a very long time on several occasion, that I believe were related with pushing to https://web.push.apple.com/....

With debug turned on I could not reproduce the delayed response, but I noticed 403 Forbidden responses from Apple.

Is the bundle known to work with Apple ?

And to prevent hanging response, what about adding a timeout in sendAsync options at src/Sender/PushMessageSender.phpL93 ?

121593 commented 5 months ago

I found the issue :

Apple has exigences on the sub claim of the JWToken.

In src/DependencyInjection/WebPushExtension.php the subject is defined this way :

$container->setParameter('bentools_webpush.vapid_subject', $config['settings']['subject'] ?? $container->getParameter('router.request_context.host'));

But in my context (CLI consumer execution, no request), there is no request and the fallback was not working. Explicitly setting the subject in the config did the trick.

It could be worth trying to find a more robust fallback, or at least adding a mention in the docs.