-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Push errors #271
Comments
What's your send notification block like? And are you using CJS or ESM? |
for (const subscription of allSubscriptions) {
console.log("Sending notification to", subscription.endpoint)
try {
sendNotifications({
notification: {
title: "Title",
options: {
body: "Body",
data: {
url: "/"
}
}
},
vapidDetails: {
publicKey: process.env.NOTIFICATION_PUBLIC_KEY as string,
privateKey: process.env.NOTIFICATION_PRIVATE_KEY as string,
},
subscriptions: [
{
endpoint: subscription.endpoint,
keys: {
p256dh: subscription.p256dh,
auth: subscription.auth,
}
}
],
options: {}
})
} catch (error) {
console.error("Error while sending notification", error) // Dont go here
}
} And im using ESM Btw another question there is a way to optimize this ? useEffect(() => {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.addEventListener("message", (event) => {
console.log("SW message", event)
if (event.data && event.data.type === "notification") {
toast({
title: event.data.title,
description: event.data.body,
action: (
<ToastAction
altText="Ouvrir"
onClick={() => navigate(event.data.url)}
>
Ouvrir
</ToastAction>
)
})
}
})
}
}, []) |
This is pretty weird, because I throw the error on purpose so it could get caught: monorepo/packages/push/server/notifications.ts Lines 16 to 25 in 6fa72a5
✅
No, there isn't. When you say optimise, do you mean whether Remix PWA offers something out of the box to shorten it? |
subscriptions.forEach(subscription => {
webpush
.sendNotification(subscription, JSON.stringify(notification), { ...options, vapidDetails: details })
.then((result: { statusCode: any }) => {
return result;
})
.catch((error: any) => {
throw new Error(error);
});
}); I cant even get the result data, typescript says its an void function And in dev mode, so with vite it make it crash
Tbh i would be prettier and easier if Remix PWA could offer something |
Oh, I think I see why. I would add this to the v5 pile I just realised why it is broken 😅 |
👍 |
Ahah okay perfect then, do you have an estimation when it will be ready ? And while im here, I dont know if its planned but there is missing types in the WebAppManifest for exemple In the display_override we can only put And the screenshots params is missing,
(https://developer.mozilla.org/en-US/docs/Web/Manifest/screenshots) The id (string) params too (https://developer.mozilla.org/en-US/docs/Web/Manifest/id) I could provide a pull request for this one if you like And the ManifestLink component doesnt provide the |
Regarding the fix, tbh I am not certain. I am currently re-working a lot of Remix PWA features, and I have to write a whole new docs for it. But I would try and get a release candidate you can download out ASAP. Remix PWA now has a manifest package btw |
Okay perfect thank you so much, and thanks for the work i love the package ! |
Sorry @Superalexandre, was super busy, but moving the changes to dev, so you can install the changes via |
https://github.com/remix-pwa/monorepo/actions/runs/11498149659/job/32003337173 - pushed to the |
Hey, no worries, i will check this soon, thanks for the work ! |
When I try to generate a
generateSubscriptionId
I got an error :Second thing, when I use the function
sendNotifications
and the subscriptions is invalid (for exemple the user have subscribed then unistall the pwa and the subscriptions is still in database)The whole process crash even in a try catch it could be nice to throw the error without crash
The text was updated successfully, but these errors were encountered: