Window.navigator.standalone
is for checking that the website is running in PWA or not, basically, I want to show a message on the website "hey, you can install it as an app too".
but I found no way other than this, especially for iOS Safari
.
please suggest in this case what do I do?
const isInWebAppiOS = window.navigator.standalone;
const isInWebAppChrome = window.matchMedia('(display-mode: standalone)')
.matches;
alert(
'isInWebAppiOS: ' +
isInWebAppiOS +
'isInWebAppChrome: ' +
isInWebAppChrome
);
this is what I have been trying.
shareClick() {
let newVariable: any;
newVariable = window.navigator;
debugger;
const isInWebAppiOS = JSON.stringify(window.navigator);
const isInWebAppChrome = window.matchMedia('(display-mode: standalone)')
.matches;
alert(
'isInWebAppiOS: ' +
isInWebAppiOS +
'isInWebAppChrome: ' +
isInWebAppChrome
);
if (newVariable && newVariable.share) {
newVariable
.share({
title: this.title,
text: this.description,
url: window.location.href
})
.then(() => console.log('Successful share'))
.catch(error => console.log('Error sharing', error));
} else {
this.dialogService.shareWithData(window.location.href);
}
}