lets deploy and see
This commit is contained in:
parent
70e7782918
commit
d063d7fb7f
@ -22,6 +22,9 @@ self.addEventListener('install', function(event) {
|
||||
});
|
||||
|
||||
self.addEventListener('push', function(event) {
|
||||
console.log('[Service Worker] Push Received.');
|
||||
console.log(`[Service Worker] Push data: "${event.data.text()}"`);
|
||||
|
||||
const data = event.data.json();
|
||||
const options = {
|
||||
body: data.body,
|
||||
|
@ -82,6 +82,28 @@
|
||||
}, function(err) {
|
||||
console.log('ServiceWorker registration failed: ', err);
|
||||
});
|
||||
|
||||
const forceResubscribeBtn = document.getElementById('force-resubscribe-btn');
|
||||
if (forceResubscribeBtn) {
|
||||
forceResubscribeBtn.addEventListener('click', function() {
|
||||
navigator.serviceWorker.ready.then(function(registration) {
|
||||
registration.pushManager.getSubscription().then(function(subscription) {
|
||||
if (subscription) {
|
||||
subscription.unsubscribe().then(function(successful) {
|
||||
if (successful) {
|
||||
console.log('Unsubscribed successfully.');
|
||||
askPermission(registration);
|
||||
} else {
|
||||
console.log('Unsubscribe failed.');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
askPermission(registration);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function askPermission(registration) {
|
||||
|
@ -15,6 +15,7 @@
|
||||
<div class="card-body">
|
||||
<button id="send-test-notification-btn" class="btn btn-primary">Send Test Notification</button>
|
||||
<button id="check-expiring-accounts-btn" class="btn btn-info">Check Expiring Accounts</button>
|
||||
<button id="force-resubscribe-btn" class="btn btn-warning">Force Re-subscribe</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user