Description
Describe the bug
We have a Progressive Web App (PWA) that can be installed on different devices. When installed as Windows app and the user allows to receive push notifications, rpush throws and error when sending it as Webpush Notification.
user.webpush_subscription on Windows:
{"endpoint"=>
"https://wns2-par02p.notify.windows.com/w/?token=BQYAAABPS6PnogyJ34%2f0sal0z2V..............",
"expirationTime"=>nil,
"keys"=>{"p256dh"=>"BCwyHsfyJhVhTEeIPbGBi.......", "auth"=>"BtCMVx................."}}
Other subscriptions are starting with https://fcm.googleapis.com
instead of https://wns2-par02p.notify.windows.com
and those work!
Now when creating and sending the notification with this code:
Rpush::Webpush::Notification.create({
app: Rpush::Webpush::App.first,
registration_ids: [user.webpush_subscription.symbolize_keys.slice(:endpoint, :keys)],
data: { message: JSON.generate({ title: message.title, url: message.url }) }
})
We got the following error:
Rpush::DeliveryError: Unable to deliver notification 83573, received error 400 (Bad Request)
Is this the wrong approach? Do we really need to set-up a Windows Store app? It would be really cool if this would just work with webpush!
i think the POST request cuts off the token query param, as seen below in the HTTP log. So if this is not cut off, we can make a successful request?!
Expected behavior
No 400 bad request error, and do not cut off the endpoint URL!
Logs and other output
From the Sentry log: - Unfortunately i don't get more information, then this:
{
method: POST,
status: 400,
url: https://wns2-am3p.notify.windows.com/w/
}
SQL:
UPDATE "rpush_notifications" SET processing = FALSE, delivered = FALSE, delivered_at = NULL, failed = TRUE, failed_at = '2024-11-06 21:14:00.857897',
error_code = 400, error_description = 'Unable to deliver notification 83573, received error 400 (Bad Request)' WHERE "rpush_notifications"."id" = $1,
Working request:
{
method: POST,
status: 201,
url: https://fcm.googleapis.com/fcm/send/<token>_
}
System configuration (please complete the following information):
- OS: Windows
- OS version: Windows 10
- Ruby version: 3.2.2
- Rails version: 7.1
- Rpush version: 9.1.0