Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 400 thrown when sending push notification to Windows devices #48

Open
ignasdamunskis opened this issue Mar 15, 2024 · 1 comment

Comments

@ignasdamunskis
Copy link

ignasdamunskis commented Mar 15, 2024

First of all, very good package, love it! I use version 0.9 since my PHP is version 7.4.

Most of the times it works as expected. Push notifications to Android Chrome and iOS Safari (90% of user devices) are sending without any issues, I had some issues with Android Firefox, it was throwing 413, but resolved decreasing the max padding length to 2847.

The issue I don't know how to resolve is sending push notifications to my clients using Windows devices, I always get an error 400 for endpoints: https://wns2-par02p.notify.windows.com/w/?token=...

I usualy log the notification errors as it happens, but since PushResponse class has no message property I can't properly debug the issue. Anyone else facing the issue, or knows how o resolve it?

@ignasdamunskis ignasdamunskis changed the title Error 400 thrown for Error 400 thrown when sending push notification to Windows devices Mar 15, 2024
@bbehrendt-mm
Copy link

bbehrendt-mm commented Apr 7, 2024

Hi! I just had the same problem myself, and found out that Microsoft requires a TTL header to be set when pushing notifications. The easiest way to fix this is by setting a default TTL for the bundle to use inside your services.yaml:

Minimal example:

    BenTools\WebPushBundle\Sender\PushMessageSender:
      arguments:
        $defaultOptions:
          TTL: 2419200

What you will likely need (to include the default VAPID params):

    BenTools\WebPushBundle\Sender\PushMessageSender:
      arguments:
        $auth:
          VAPID:
            subject: '%bentools_webpush.vapid_subject%'
            publicKey: '%bentools_webpush.vapid_public_key%'
            privateKey: '%bentools_webpush.vapid_private_key%'
        $defaultOptions:
          TTL: 2419200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants