我正在使用angularjs的web应用程序项目,它有移动应用程序,他们是android和Ios。现在我想要在移动设备上打开Web应用程序时我需要找到设备类型并检查是否安装了移动应用程序,如果安装应该在移动应用程序中打开,如果没有下载按钮是app-link.Thanks in预先
使用$window
服务,
你可以像这样检查一下
var userAgent = $window.navigator.userAgent;
/(iPhone|iPad|iPod).* OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent);
function checkOperatingSystem()
{ var userAgent = navigator.userAgent || navigator.vendor || window.opera;
//Check mobile device is Android
if (/android/i.test(userAgent)) {
//Add your Code here
}
//Check mobile device is IOS
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
//Add your Code here
}
//Check device os is Windows (For Laptop and PC)
if (navigator.appVersion.indexOf("Win")!=-1)
{
//Add your Code here
}
//Check device os is MAC (For Laptop and PC)
if (navigator.appVersion.indexOf("Mac")!=-1)
{
//Add your Code here
}
}