我试图通过SAMSUNG Internet将网页发布为PWA应用程序。我想使用自定义的“添加到主屏幕”弹出窗口。为此,我必须使用以下事件,并且我想听听用户的选择。在Chrome中,用户选择会在用户选择后触发。但是在三星互联网上它对此没有反应......有人可以帮我吗?
谢谢
window.addEventListener('beforeinstallprompt', function (e) {
deferredPrompt = e;
deferredPrompt.preventDefault();
deferredPrompt.then((choice) => {
if (choice.outcome === 'accepted') {
console.log('User accepted the A2HS prompt');
} else {
console.log('User dismissed the A2HS prompt');
}
// Clear the saved prompt since it can't be used again
installPromptEvent = null;
});
})
来自caniuse Samsung Internet不支持beforeinstallprompt
,并且不支持appinstalled
事件。
参考:https://caniuse.com/#feat=web-app-manifest
因此您将完全无法以这种方式使用它。