是否可以在Edge (win10)中自动添加桌面PWA ?



我正在开发PWA,我设法通过Edge在win10上安装它。它是作为Windows应用程序安装的,也可以在Edge应用程序部分找到,但是,这个应用程序没有出现在我的桌面。

要在安装后将其添加到我的桌面屏幕,我需要执行以下步骤:

  1. 打开Edge的应用程序设置
  2. 转到管理应用程序选项卡
  3. 右键点击我的应用打开应用上下文菜单
  4. 点击PIN菜单
  5. 点击Pin to desktop

关于如何将PWA添加到Desktop中,这是一种非常漫长且不直观的UX方式,对于不熟悉所有这些细微差别的用户来说,很难做到这一点。

在Chrome中,PWA快捷方式自动添加到桌面,我希望在Edge的情况下也有这种行为(如果可能的话,肯定的)。

所以我的问题是:在用户点击安装按钮并确认安装后,是否可以默认在桌面屏幕上添加PWA ?

感谢任何帮助或信息!

你可以添加一个安装横幅到你的应用程序。你没有提到你使用的是哪个库,我用react:

function App() {
const deferredPrompt = useRef(null);
const [installBannerVisible, setInstallBannerVisible] = useState(false);
useEffect(() => {
window.addEventListener("beforeinstallprompt", (e) => {
e.preventDefault();
deferredPrompt.current = e;
showInstallPromotion();
});
}, []);
const showInstallPromotion = () => {
setInstallBannerVisible(true);
};
const handleButtonClick = () => {
deferredPrompt.current.prompt();
deferredPrompt.current.userChoice.then((choiceResult) => {
if (choiceResult.outcome === "accepted") {
console.log("User accepted the install prompt");
} else {
console.log("User dismissed the install prompt");
}
});
};
return (
<div>
{installBannerVisible && (
<button onClick={handleButtonClick}>Install</button>
)}
</div>
);
}

确保你的浏览器支持beforeinstallprompt.

我在最新版本的Microsoft Edge上进行了测试。

更多信息

最新更新