Gui*_*ère 24 javascript download progressive-web-apps
我最近发布了一个服务器渲染的渐进式网络应用程序,到目前为 但是,使用Chrome的Android会显示一个横幅来下载应用程序,这很棒,但它不适用于iOS.使用Safari,用户只需点击几下即可进入"添加到主屏幕"功能,这很糟糕.
所以我在这里,我对我的PWA很满意,但我真的很想能够告诉用户自己这个应用程序可以添加到主屏幕.
据我所知,我看到https://marvelapp.com/这样做是为了在主屏幕上添加原型.
Ala*_*lan 33
目前,Apple 无法让这种“添加到主屏幕”体验变得简单。
详细说明在这里:https : //www.netguru.com/codestories/few-tips-that-will-make-your-pwa-on-ios-feel-like-native
在部分: 技巧 3:自己创建一个“添加到主屏幕”弹出窗口!
Ana*_*and 19
iOS - Safari目前不支持Web应用安装横幅,例如Android - Chrome.
有没有办法以编程方式触发在Android中,当你赶上beforeInstallPromot安装旗帜以及除的情况下,并用它来展现旗帜.
在链接的答案中,您可以查看有关如何在应用横幅中显示的备用选项,以指导用户添加到主屏幕.下面是一些相同的代码示例,它是iOS特定的(在#PROTIP 3下查看).
请注意,Chrome(Android 上)是唯一自动提示用户安装 PWA 的浏览器。您应该手动处理 iOS 和其他 Android 浏览器。 统计数据显示(2021 年更新),排名前 3 的移动浏览器是 Chrome、Safari 和三星互联网(<6%)。
您可以使用此代码来帮助您提示:
// helps you detect mobile browsers (to show a relevant message as the process of installing your PWA changes from browser to browser)
var isMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function () {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function () {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function () {
return navigator.userAgent.match(/Opera Mini/i);
},
Samsung: function () {
return navigator.userAgent.match(
/SAMSUNG|Samsung|SGH-[I|N|T]|GT-[I|N]|SM-[A|N|P|T|Z]|SHV-E|SCH-[I|J|R|S]|SPH-L/i,
);
},
Windows: function () {
return (
navigator.userAgent.match(/IEMobile/i) ||
navigator.userAgent.match(/WPDesktop/i)
);
},
any: function () {
return (
isMobile.Android() ||
isMobile.BlackBerry() ||
isMobile.iOS() ||
isMobile.Opera() ||
isMobile.Windows()
);
},
};
// use this to check if the user is already using your PWA - no need to prompt if in standalone
function isStandalone(): boolean {
const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
if (document.referrer.startsWith("android-app://")) {
return true; // Trusted web app
} else if ("standalone" in navigator || isStandalone) {
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
至于安装说明:
Chrome - auto
Safari - Press "Share" icon then "Add to home"
Samsung internet - An "Install" icon will be shown on the top bar (I didn't quite understand if the app should be registered in Samsung Store for it to show) OR press "Menu" on the bottom bar then "Add/install to home"
Other browsers - Press menu on the bottom/top bar then "Add/install to home"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21829 次 |
| 最近记录: |