Initial independent version of CrAPP
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 209 KiB |
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "CrAPP — CRAP Volley",
|
||||
"short_name": "CrAPP",
|
||||
"description": "L'app della squadra CRAP Volley: presenze, calendario, statistiche, classifica e scout live.",
|
||||
"start_url": "/",
|
||||
"display": "standalone",
|
||||
"background_color": "#111111",
|
||||
"theme_color": "#111111",
|
||||
"orientation": "portrait",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/icon-192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Service worker dedicato alle notifiche push del turno palloni.
|
||||
// Non memorizza nella cache pagine o asset dell'app.
|
||||
|
||||
self.addEventListener("install", () => self.skipWaiting());
|
||||
self.addEventListener("activate", (event) => event.waitUntil(self.clients.claim()));
|
||||
|
||||
async function testoNotifica() {
|
||||
try {
|
||||
const sub = await self.registration.pushManager.getSubscription();
|
||||
if (!sub) return null;
|
||||
const res = await fetch("/api/public/push-messaggio", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ endpoint: sub.endpoint }),
|
||||
});
|
||||
if (!res.ok) return null;
|
||||
return await res.json();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
self.addEventListener("push", (event) => {
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const dati = await testoNotifica();
|
||||
await self.registration.showNotification(dati?.title ?? "CrAPP · Turno palloni", {
|
||||
body: dati?.body ?? "Controlla il turno palloni di oggi.",
|
||||
icon: "/icon-192.png",
|
||||
badge: "/icon-192.png",
|
||||
tag: "turno-palloni",
|
||||
});
|
||||
})(),
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("notificationclick", (event) => {
|
||||
event.notification.close();
|
||||
event.waitUntil(
|
||||
self.clients.matchAll({ type: "window", includeUncontrolled: true }).then((clientList) => {
|
||||
const aperto = clientList.find((c) => "focus" in c);
|
||||
if (aperto) return aperto.focus();
|
||||
return self.clients.openWindow("/");
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
User-agent: Googlebot
|
||||
Allow: /
|
||||
|
||||
User-agent: Bingbot
|
||||
Allow: /
|
||||
|
||||
User-agent: Twitterbot
|
||||
Allow: /
|
||||
|
||||
User-agent: facebookexternalhit
|
||||
Allow: /
|
||||
|
||||
User-agent: *
|
||||
Allow: /
|
||||
Reference in New Issue
Block a user