static/sw.js
function persistSubscriptionLocally(subscription) {
    let subscriptionJSON = JSON.stringify(subscription);
    idb.open('web-push-db', 1).then(db => {
        let tx = db.transaction(['web-push-subcription'], 'readwrite');
        tx.objectStore('web-push-subcription').put({
            id: 1,
            data: subscriptionJSON
        });
        return tx.complete;
    });
}
function persistSubscriptionLocally(subscription) {
    let subscriptionJSON = JSON.stringify(subscription);
    idb.open('web-push-db', 1).then(db => {
        let tx = db.transaction(['web-push-subcription'], 'readwrite');
        tx.objectStore('web-push-subcription').put({
            id: 1,
            data: subscriptionJSON
        });
        return tx.complete;
    });
}
function persistSubscriptionLocally ( subscription ) { let subscriptionJSON = JSON . stringify ( subscription ) ; idb . open ( 'web-push-db' , 1 ) . then ( db => { let tx = db . transaction ( [ 'web-push-subcription' ] , 'readwrite' ) ; tx . objectStore ( 'web-push-subcription' ) . put ( { id : 1 , data : subscriptionJSON } ) ; return tx . complete ; } ) ; }
Helper functions for IndexedDB management.
 
Persists the subscription object in IndexedDB.
Helper functions for IndexedDB management . Persists the subscription object in IndexedDB .