如何查找Web应用程序打开的设备(移动(Android或Ios)或桌面)

问题描述 投票:-2回答:2

我正在使用angularjs的web应用程序项目,它有移动应用程序,他们是android和Ios。现在我想要在移动设备上打开Web应用程序时我需要找到设备类型并检查是否安装了移动应用程序,如果安装应该在移动应用程序中打开,如果没有下载按钮是app-link.Thanks in预先

android jquery ios angularjs mobile
2个回答
0
投票

使用$window服务,

你可以像这样检查一下

var userAgent = $window.navigator.userAgent;

/(iPhone|iPad|iPod).* OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent);

1
投票
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
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.