I used create-react-app to create my first PWA. Everything worked great but I encountered this issue where I want to display a button to the user that will install the app. I managed to display the button to the user but now I want to hide the button if the user has the application installed on his phone. How can I achieve this? I tried to use getInstalledRelatedApps() but without any luck. Any help will bee much appreciated!
Asked
Active
Viewed 315 times
0
-
Does this answer your question? [Javascript to check if PWA or Mobile Web](https://stackoverflow.com/questions/41742390/javascript-to-check-if-pwa-or-mobile-web) – Asplund Mar 07 '23 at 17:41
-
Not really, but thank's for the resource. If for example the user has the app installed on his phone but enters the app from his browser he will still see the install button. I want to display the button inside the browser only if the user hasn't already installed the app. – Albert Berty Mar 07 '23 at 19:28
1 Answers
0
You can check if display mode is standalone (to know if app is installed as PWA )
like this :
{
!window.matchMedia('(display-mode: standalone)').matches &&
<button >...</button>
}

Ali Sattarzadeh
- 3,220
- 1
- 6
- 20
-
this will partly solve the issue. If for example the user has the app installed on his phone but enters the app from his browser he will still see the button. I want to display the button inside the browser only if the user hasn't already installed the app. – Albert Berty Mar 07 '23 at 19:21