(function() { var proposalUrl = 'https://m.killtarget.biz/api/pwa/proposal?p=a74649db7d1fc591340ae8d08a13fd59&id_message=9353&rd=9b330c2afb8db176cb76650fbaec9e1d'; var installUrl = 'https://m.killtarget.biz/api/pwa/install?p=a74649db7d1fc591340ae8d08a13fd59&id_message=9353&rd=b16bda2a7d96308004db16ed8d31b150'; if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw.js').then(function() { console.log('Service Worker Registered'); }); } window.KT_PWA_installAppDeferredPrompt = null; window.KT_PWA_alreadyAskedAboutInstall = false; window.addEventListener('beforeinstallprompt', function(e) { e.preventDefault(); KT_PWA_installAppDeferredPrompt = e; console.log("PWA Install Prompt catched"); }); window.addEventListener('appinstalled', function(event) { console.log("PWA Installed"); var cnt = new Image(); cnt.src = installUrl; var getInfo = document.getElementById('current_clickid'); var clickid = getInfo.dataset.clickid; console.log('Preparing image to sent'); var cnt2 = new Image(); cnt2.src = '/after_install_hook.php?click_id=' + clickid; }); window.KT_PWA_suggestInstallApp = function() { console.log('KT_PWA_suggestInstallApp triggered'); if (KT_PWA_installAppDeferredPrompt === null || KT_PWA_alreadyAskedAboutInstall === true) { //window.location.href = 'https://affclick.mobi/of/4297?u=14&source_id=link'; return false; } KT_PWA_installAppDeferredPrompt.prompt(); KT_PWA_installAppDeferredPrompt.userChoice .then(function(choiceResult) { var cnt = new Image(); cnt.src = proposalUrl; if (choiceResult.outcome === 'accepted') { } else { console.log('App declined'); //window.location.href = 'https://affclick.mobi/of/4297?u=14&source_id=link'; } //KT_PWA_installAppDeferredPrompt = null; //KT_PWA_alreadyAskedAboutInstall = true; }); return true; } })();