getInstalledRelatedApps() API 未检测到已安装的应用程序
Posted
技术标签:
【中文标题】getInstalledRelatedApps() API 未检测到已安装的应用程序【英文标题】:getInstalledRelatedApps() API not detecting the installed app 【发布时间】:2021-06-23 06:03:21 【问题描述】:我一直在尝试使用 jquery.smartbanner.js 在 smartbanner 中实现 getInstalledRelatedApps API 以在我的项目中工作,但是如下所示的 relatedApps const 返回空,并且承诺的状态始终处于“待定” ”。下面附上承诺的截图:
(async function ()
alert("running");
const relatedApps = await navigator.getInstalledRelatedApps();
alert(relatedApps);
console.log(relatedApps);
relatedApps.forEach((app) =>
console.log(app.id, app.platform, app.url);
);
)();
manifest.json 如下:
"name": "Example",
"short_name": "Example",
"lang": "en-US",
"theme_color": "#192c4f",
"background_color": "#192c4f",
"display": "standalone",
"scope": "/",
"start_url": "/",
"icons": [
"src": "images/36.png",
"sizes": "36x36",
"type": "image/png"
,
"src": "images/48.png",
"sizes": "48x48",
"type": "image/png"
,
"src": "images/72.png",
"sizes": "72x72",
"type": "image/png"
,
"src": "images/96.png",
"sizes": "96x96",
"type": "image/png"
,
"src": "images/144.png",
"sizes": "144x144",
"type": "image/png"
,
"src": "images/192.png",
"sizes": "192x192",
"type": "image/png"
],
"splash_pages": null,
"prefer_related_applications": true,
"related_applications": [
"platform": "play",
"id": "com.example.android"
]
Playstore 应用 ID 已从 android 应用端进行了双重检查。 任何帮助将不胜感激,谢谢!
【问题讨论】:
您是否按照以下所有步骤操作:Check if your Android app is installed 是的,所有步骤都遵循了,一切都按照教程的建议完成了。 【参考方案1】:更改相关应用对象
1- 对于 PWA,平台必须是“webapp”
2- url 是 PWA 的 Web 应用清单的完整路径
“相关应用程序”:[ “平台”:“网络应用程序”, "url": "https://example.com/manifest.json", ]
【讨论】:
以上是关于getInstalledRelatedApps() API 未检测到已安装的应用程序的主要内容,如果未能解决你的问题,请参考以下文章