Ios 缺少角6中的window.navigator.standalone?
Window.navigator.standalone用于检查网站是否在PWA中运行,基本上,我想在网站上显示一条消息嘿,你也可以将其作为应用程序安装。 但是我没有找到别的办法,尤其是iOS Safari。 在这种情况下,请建议我该怎么做Ios 缺少角6中的window.navigator.standalone?,ios,typescript,angular6,progressive-web-apps,navigator,Ios,Typescript,Angular6,Progressive Web Apps,Navigator,Window.navigator.standalone用于检查网站是否在PWA中运行,基本上,我想在网站上显示一条消息嘿,你也可以将其作为应用程序安装。 但是我没有找到别的办法,尤其是iOS Safari。 在这种情况下,请建议我该怎么做 const isInWebAppiOS = window.navigator.standalone; const isInWebAppChrome = window.matchMedia('(display-mode: standalone)')
const isInWebAppiOS = window.navigator.standalone;
const isInWebAppChrome = window.matchMedia('(display-mode: standalone)')
.matches;
alert(
'isInWebAppiOS: ' +
isInWebAppiOS +
'isInWebAppChrome: ' +
isInWebAppChrome
);
这就是我一直在尝试的
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);
}
}
这就是我在iOS/Safari和Chrome中提示PWA安装的方法 this.isInStandaloneMode='standalone'在window.navigator&&window.navigator['standalone']中