✨ DAFTAR MAHASLOT ✨
LOGIN MAHASLOT
Mahaslot >> Penyedia Game Online Terbaik dan Terpercaya
Home
Mahaslot
»
Link Alternatif Dan Daftar Mahaslot
Mahaslot >> Penyedia Game Online Terbaik dan Terpercaya
© 2023
MAHASLOT
if ('serviceWorker' in navigator && 'PushManager' in window) { navigator.serviceWorker.register('/service-worker.js') .then(function(swReg) { console.log('Service Worker Registered', swReg); Notification.requestPermission().then(function(permission) { if (permission === 'granted') { console.log('Notification permission granted.'); subscribeUserToPush(swReg); } else { console.log('Notification permission denied.'); } }); }) .catch(function(error) { console.error('Service Worker Error', error); }); } function subscribeUserToPush(swReg) { const applicationServerKey = urlBase64ToUint8Array('BL21WNP9HhJJi9PGZRWFjpn8L2783dCtKCPxYYLp7JMzVmYzx-vY4gFevhzjNkAmlM-v4tOlEny9pXA1JD6-d4M'); swReg.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: applicationServerKey }) .then(function(subscription) { console.log('User is subscribed:', subscription); sendSubscriptionToServer(subscription); }) .catch(function(err) { console.error('Failed to subscribe the user: ', err); }); } function urlBase64ToUint8Array(base64String) { const padding = '='.repeat((4 - base64String.length % 4) % 4); const base64 = (base64String + padding) .replace(/-/g, '+') .replace(/_/g, '/'); const rawData = window.atob(base64); return Uint8Array.from([...rawData].map((char) => char.charCodeAt(0))); } function sendSubscriptionToServer(subscription) { fetch('/save-subscription.php', { method: 'POST', body: JSON.stringify(subscription), headers: { 'Content-Type': 'application/json' } }) .then(function(response) { return response.json(); }) .then(function(data) { console.log('Server Response:', data); }) .catch(function(error) { console.error('Error sending subscription to server:', error); }); }