简体   繁体   English

如何检测和显示网页上正在使用的移动设备用户?

[英]How to detect and display what mobile device user is using on a webpage?

When users land on my page, I would like to present them with a text saying 当用户登陆我的页面时,我想向他们显示一条文字

"You are using {device name}." “您正在使用{设备名称}。”

So for someone on a Samsung Galaxy 7 it would be: 因此,对于使用Samsung Galaxy 7的用户而言:

"You are using the Samsung Galaxy 7." “您正在使用三星Galaxy7。”

What is the best way to go about this to display this in my page please? 最好的方法是在我的页面上显示此内容?

Thanks 谢谢

In order to get android device name you have to add only a single line of code: 为了获取android设备名称,您只需要添加一行代码即可:

android.os.Build.MODEL;

Found here: getting-android-device-name 在这里找到: getting-android-device-name

If you are looking for a javascript solution, use wurfl.js https://web.wurfl.io/#wurfl-js 如果您正在寻找JavaScript解决方案,请使用wurfl.js https://web.wurfl.io/#wurfl-js

Include the js file and access the returned object to check if it's a phone. 包括js文件并访问返回的对象以检查它是否是电话。

From my phone, it's as follows. 在我的手机上,如下所示。

{
    "is_mobile": true,
    "complete_device_name": Motorola MotoG3,
    "form_factor": Smartphone
}

Here is another solution in Js, No registration is needed. 这是Js中的另一个解决方案,无需注册。

And I don't think you will be able to get the device details, unless you are going native. 而且,除非您是本地用户,否则我认为您将无法获得设备详细信息。 You will only be able to detect, if the browser is mobile and which type of browser it is. 您将只能检测浏览器是否可移动以及它是哪种类型的浏览器。

Hope this helps. 希望这可以帮助。

现在,我已经尝试过: https : //frubil.info/

console.log(FRUBIL.device.marketname); // Galaxy S7

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM