diff --git a/public/service-worker.js b/public/service-worker.js new file mode 100644 index 0000000..3eadbb5 --- /dev/null +++ b/public/service-worker.js @@ -0,0 +1,29 @@ +/* cod para manejar push */ + +self.addEventListener("push", e => { + console.log(e); + + try { + const datos = JSON.parse(e.data.text()); + + const titulo = datos.titulo; + const cuerpo = datos.cuerpo; + const icono = datos.icono; + const tipo = datos.tipo; + + e.waitUntil( + self.registration.showNotification(titulo, { + body: cuerpo, + icon: icono + }) + ); + } catch (err) { + e.waitUntil( + self.registration.showNotification("Ejemplo", { + body: e.data.text(), + icon: "https://pseudosubs.com/favicon.png" + }) + ); + } + +}); \ No newline at end of file