Nutstack PWA Manifest

This commit is contained in:
lemonknowsall committed 2025-10-20 13:25:54 -07:00
1 parent 24920117ae
commit 1c991e3185
5 files changed
+67

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 KiB

+21
View File
@@ -0,0 +1,21 @@
{
"name": "NutStack",
"short_name": "NutStack",
"description": "Nostr application with Cashu wallet integration",
"start_url": "/",
"display": "standalone",
"background_color": "#000000",
"theme_color": "#000000",
"icons": [
{
"src": "/icon-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/icon-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
+33
View File
@@ -0,0 +1,33 @@
// public/sw.js
self.addEventListener("push", (event) => {
if (!event.data) return;
try {
const data = event.data.json();
const title = data.title || "New Notification";
const options = {
body: data.body,
icon: data.icon || "/icon-192.png"
// badge: data.badge || "/badge-72x72.png",
// data: data.data || {},
};
event.waitUntil(
self.registration.showNotification(title, options)
);
} catch (err) {
console.error("Push event error:", err);
}
});
self.addEventListener("notificationclick", (event) => {
event.notification.close();
// If you send a `url` in payload.data, open it
const url = event.notification.data?.url;
if (url) {
event.waitUntil(clients.openWindow(url));
}
});
+13
View File
@@ -15,3 +15,16 @@ createRoot(document.getElementById("root")!).render(
<App />
</ErrorBoundary>
);
// Register service worker for PWA
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then((registration) => {
console.log('SW registered: ', registration);
})
.catch((registrationError) => {
console.log('SW registration failed: ', registrationError);
});
});
}