Bottone attivazione push – pronto per il sito

Inserisci questo codice nelle pagine dove vuoi permettere agli utenti di attivare le notifiche.

1. Script (in <head> o prima di </body>)

<script src="https://TUO-DOMINIO/api-push/embed-e2ee-basic.js" data-api-base="https://TUO-DOMINIO/api-push"></script>

Sostituisci TUO-DOMINIO con l'URL dove gira Willy Push (es. willypush.it o localhost/Willy_push/httpdocs).

2. Bottone

<button onclick="WillyPushE2EE.askPermission().then(function(){alert('Notifiche attivate!');}).catch(function(e){alert(e.message);});">
  🔔 Attiva notifiche
</button>

Oppure con segmento (es. per utenti VIP):

<button onclick="WillyPushE2EE.askPermission({role:'vip'}).then(function(){alert('Attivato!');});">
  🔔 Notifiche VIP
</button>

Anteprima