[英]BeforeinstallPromt event fired still Add to home screen Prompt not working after setting any value in window.location
在 window.location 中設置任何值后,谷歌的添加到主屏幕功能不起作用。
到目前為止做了什么?
參考:web-fundamentals-app-install-banners
在此實施期間,我正在捕獲 window 的'beforeInstallPromptEvent'
,並在以后需要時使用它。
PFB 相同的代碼片段:
window.addEventListener('beforeinstallprompt', (e) => {
deferredPrompt = e;
// Update UI notify the user they can add to home screen
showInstallPromotion();
});
btnAdd.addEventListener('click', (e) => {
// hide our user interface that shows our A2HS button
btnAdd.style.display = 'none';
// Show the prompt
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
deferredPrompt.userChoice
.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
console.log('User accepted the A2HS prompt');
} else {
console.log('User dismissed the A2HS prompt');
}
deferredPrompt = null;
});
});
上面的代碼在正常的旅程中完美運行,但是一旦我在 window.location 到 go 包含一些安裝在設備中的應用程序,它就會停止工作,
當 Truecaller 功能的以下代碼與添加到主屏幕一起添加時,它會停止工作:
window.location='xxxxxsdk://some-url/';
我還嘗試使用其他選項重定向到諸如location.assign()
之類的應用程序,但仍然是同樣的問題。
嗨)安裝應用程序后嘗試放置:
window.addEventListener('appinstalled', function() {
// window.location = ...
});
這是文檔: https://developer.mozilla.org/en-US/docs/Web/API/Window/appinstalled_event
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.