Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use to detect device on website access? #145

Closed
haizen007 opened this issue Jul 2, 2022 · 2 comments
Closed

How can I use to detect device on website access? #145

haizen007 opened this issue Jul 2, 2022 · 2 comments

Comments

@haizen007
Copy link

I want to detect the phone model and OS of every mobile access to a website.
How can I use this lib for that?
Thanks

@etienne-martin
Copy link
Owner

Hi there, I would first check the documentation or ask people over on StackOverflow for help.

Let me know if the documentation could be improved.

@yCodeTech
Copy link

yCodeTech commented Apr 8, 2023

I vote to reopen this issue. The documentation is a little bit sparse. With only 1 example, albeit a poor example for the user agent detection:

import DeviceDetector from "device-detector-js";

const deviceDetector = new DeviceDetector();
const userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36";
const device = deviceDetector.parse(userAgent);

console.log(device);

Typically, nobody would manually type in a userAgent string like that, it would be done via window.navigator.userAgent or other means (I'm not sure if there are other ways). Also, we shouldn't technically have to feed in the useragent ourselves, this should be detected and handled automatically by the library. However, that's by the by. What the documentation really needs is specifying whether it has any methods or ways to tell us what type of device it is. Like isMobile or isDesktop, or isTablet, just like there is in the php library. There is no reasonable way to deduce that the methods are exactly the same as in the php library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants