我正在学习渐进式网络应用程序,并且我已经在具有所有 PWA 配置的角度应用程序上创建了。然后我在 firebase 上托管该应用程序,并在我的 Android 手机上打开它,并成功收到将应用程序添加到主屏幕的提示。
但现在我已经更改了清单文件和index.html 文件中的应用程序图标,然后再次部署了该应用程序,但手机上的主屏幕图标没有更新。我尝试卸载该应用程序然后重新安装,但它仍然在我的手机上显示旧图标。
所以我的问题是,如何更新用户设备上的主屏幕图标?这是我的配置文件。
manifest.json
{
"short_name": "My Expense",
"name": "Log My Expense",
"start_url": "/",
"theme_color": "#5FD4AF",
"background_color": "#ffffff",
"display": "standalone",
"orientation": "portrait",
"icons": [
{
"src": "/assets/icons/cash-money-wallet_64.png",
"sizes": "64x64",
"type": "image/png"
},
{
"src": "/assets/icons/cash-money-wallet_128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "/assets/icons/cash-money-wallet_256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "/assets/icons/cash-money-wallet_512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
ngsw-config.json
{
"index": "/index.html",
"assetGroups": [{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html"
],
"versionedFiles": [
"/*.bundle.css",
"/*.bundle.js",
"/*.chunk.js"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**"
]
}
}]
}
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>LogMyExpensePwa</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="/assets/icons/cash-money-wallet_512.png">
<link rel="manifest" href="/manifest.json">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="msapplication-starturl" content="/">
<meta name="theme-color" content="#5FD4AF">
</head>
<body>
<app-root></app-root>
<noscript>
JavaScript is required to run this application.
</noscript>
</body>
</html>
听起来你在上面的评论中得到了答案,我只是想提出一些对我有帮助的东西。我的应用程序是在 React 而不是 Angular 中(我是一个菜鸟,所以我不知道这是否重要,但我想记下以防万一),当我尝试在 src 中包含应用程序图标时(我的是在“/assets”中,就像你的一样)它没有通过刷新来更新图标。在这里要非常明确的是,我只尝试了一次 - 但 DevTools 中的应用程序选项卡也没有看到我的图标。因此,我将图标放在图像文件夹中的公共文件夹中,当我重新安装应用程序时,它的图标变得完美。我已经有那个文件夹来存放我的选项卡图标(忘记了它的技术术语),所以我不觉得我添加了任何使我的应用程序膨胀的东西,但这是我的意见。
不知道这是否有帮助,我没有深入这个兔子洞试图找出为什么我的没有在 src/assets 中捕获图像。