-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
device has properties with undefined value #182
Comments
@aifrim it's an interesting subject for discussion. Desktops/Laptops Browsers don't have an indication telling that they are actually running on such devices ( as opposed to tablets/smartphones that have the model incorporated into the UA String ). You can transitively deduce it's a "pc" by ruling out other options/applying other heuristics ( say, windows 7 only runs on pc, so it must be a pc ) But I don't think that logic is something you should implement on the framework level, because the permutations are endless. I personally think ua-parser-js should stick to identifications it can make directly as opposed to indirect,transitive ones @faisalman WDYT ? |
Completely agree with @sheinbergon in this regard. I decide to not adding this for the moment, maybe sometime in the near future.. Thanks for your suggestion 👍 |
I totally get the explanation, would be great if the docs indicated this though. |
Speaking as a developer trying to solve a problem, while I understand this reasoning, it seems like a hole in the library's functionality. The many requests closed over the years seem to hint that others have the same issue. Respectfully, is it possible to revisit this decision? |
Hi all 👋 I have a web app with two breakpoints:
On the server, I need to use the user-agent to determine which regime I'm in. Does the following logic seem like a reasonable approach to you? switch (device.type) {
case 'wearable':
case 'mobile':
// Device width probably less than 768px. Show mobile version of app.
return 'mobile';
case 'console':
case 'tablet':
case 'smarttv':
case 'embedded':
case undefined:
default:
// Device width probably greater than 768px. Show desktop version of app.
return 'desktop';
} It's obviously not perfect e.g. if someone is on a tall phone (> 768px) and they're in horizontal mode, then we'll still show the "mobile" UI even though the screen width is > 768px. But it seems like this will work in ~95% of use cases? |
Did this work. Stuck on same thing |
You can also use: const isDesktop = device.type === undefined || !['wearable', 'mobile'].includes(device.type); |
Windows 7 Enterprise:
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Windows 10 Enterprise:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
I suggest adding the model as being
pc
The text was updated successfully, but these errors were encountered: