在 android 上安装 manifest.json
Install a manifest.json on android
我正在尝试在此处构建渐进式 Web 应用程序:https://121eddie.github.io。这涉及
- a manifest.json 用于安装和提示访问权限
- 用于离线缓存的服务工作者。 (它安装正确但由于某种原因从未接听离线电话)
以下 manifest.json 得到了 https://manifest-validator.appspot.com/ 的验证。
{
"name": "Determiner ma position et la partager",
"short_name": "PositionWeb",
"start_url": "/index.html",
"homepage_url":"https://121eddie.github.io/",
"display": "standalone",
"description": "Une application Web Progressive qui permet de connaitre sa position et de la telecharger ou partager, meme en mode offline",
"lang": "fr-FR",
"scope": "/",
"background_color": "lightyellow",
"theme_color": "lightgreen",
"permissions": [
"geolocation",
"fileSystem",
"fileSystem.write",
"notifications"
],
"icons": [{"src": "icon200.png","sizes": "200x200","type": "image/png"},
{"src": "icon512.png","sizes": "512x512","type": "image/png"}
]
}
它在 index.html 中加载
<link rel="manifest" href="manifest.json">
然而 Google Chrome 我得到
SytaxError: unexpected token in JSON on position 0
错误在哪里?
更新
我改进了以下几个方面
- 我添加了一个图标
- 我用 utf-8 编码(而不是 ansi)
- 我加了一个favicon.ico
解决方案
防止 Notepad++ 在第一个括号前自动添加 space
The bare minimum requirement for a web manifest is name and at least one icon (with src, size and type).
所以,至少你的清单缺少图标
是编者:即使是utf-8保存,记事本在第一个中括号“{”前加了一个space,使代码无效。请谨慎选择 JSON 编辑器!
我正在尝试在此处构建渐进式 Web 应用程序:https://121eddie.github.io。这涉及
- a manifest.json 用于安装和提示访问权限
- 用于离线缓存的服务工作者。 (它安装正确但由于某种原因从未接听离线电话)
以下 manifest.json 得到了 https://manifest-validator.appspot.com/ 的验证。
{
"name": "Determiner ma position et la partager",
"short_name": "PositionWeb",
"start_url": "/index.html",
"homepage_url":"https://121eddie.github.io/",
"display": "standalone",
"description": "Une application Web Progressive qui permet de connaitre sa position et de la telecharger ou partager, meme en mode offline",
"lang": "fr-FR",
"scope": "/",
"background_color": "lightyellow",
"theme_color": "lightgreen",
"permissions": [
"geolocation",
"fileSystem",
"fileSystem.write",
"notifications"
],
"icons": [{"src": "icon200.png","sizes": "200x200","type": "image/png"},
{"src": "icon512.png","sizes": "512x512","type": "image/png"}
]
}
它在 index.html 中加载
<link rel="manifest" href="manifest.json">
然而 Google Chrome 我得到
SytaxError: unexpected token in JSON on position 0
错误在哪里?
更新
我改进了以下几个方面
- 我添加了一个图标
- 我用 utf-8 编码(而不是 ansi)
- 我加了一个favicon.ico
解决方案
防止 Notepad++ 在第一个括号前自动添加 space
The bare minimum requirement for a web manifest is name and at least one icon (with src, size and type).
所以,至少你的清单缺少图标
是编者:即使是utf-8保存,记事本在第一个中括号“{”前加了一个space,使代码无效。请谨慎选择 JSON 编辑器!