Is there an way to check if the PWA app is already installed?
can prompt event can be cancelled may be in 'beforeinstallprompt'
event
window.addEventListener('beforeinstallprompt', (event) => {
// in here
});
Note: This specifically happening in oneplus 6T (chrome) and all other phones this works fine
If a user is using Google Chrome, the following will be relevant:
Add to Home Screen
By Pete LePage
https://developers.google.com/web/fundamentals/app-install-banners/
Quote:
In order for a user to be able to install your Progressive Web App, it needs to meet the following criteria:
- The web app is not already installed.
Also, when the user has successfully installed the app, there is a callback from the appinstalled
event. You can use this to persist the fact that the user has installed the app (perhaps in localStorage or indexedDB):
Quote:
Determine if the app was successfully installed
To determine if the app was successfully added to the user's home screen after they accepted the prompt, you can listen for the
appinstalled
event.window.addEventListener('appinstalled', (evt) => { app.logEvent('a2hs', 'installed'); });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.