I want show a button that open pwa version of my website if user has installed it.
I have tried navigator.getInstalledRelatedApps()
but always return empty array. The PWA in installed, the browser show the icon
into manifest.json I have defined related_applications
"scope": "/",
"start_url": "/?utm_source=pwa",
"related_applications": [
{
"platform": "webapp",
"url": "https://my-app.com/manifest.json"
}
]
Why navigator.getInstalledRelatedApps()
return empty array ?
> navigator.getInstalledRelatedApps().then(console.log)
> []
navigator.getInstalledRelatedApps()
return empty array also if I open the PWA instead of navigate via browser
In your question, you do not specify the OS or the browser.
To my knowledge navigator.getInstalledRelatedApps has never been supported on Safari/iOS. For now, let me assume you are using Chrome on Android.
In that combination, navigator.getInstalledRelatedApps returns an empty array starting with Android 12. It is also present in Android 13 according to the author of this bug report. https://bugs.chromium.org/p/chromium/issues/detail?id=1450328
It is labeled as a bug/regression. Although one can see that the Chromium team have categorized the issue, there is no owner assigned. I advocate taking a moment to create an ID and voting for the bug if you need this functionality.