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

Added phoneType function #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ThorstenBux
Copy link

Hi, I need to get the actual phone Type not only the manufacturer or vendor from the userAgent string. As it looks the type is available on WebKit phones on AndroidOS. I don't have many Android phones to test (only three) but it works on those. Also, the algorithm might not be sufficient for all cases.

I'd like to get some feedback on this proposed feature (function) for mobile-detect.js. I'm happy to adapt the code or follow another path, just let me know.

Thanks

@hgoebl
Copy link
Owner

hgoebl commented Dec 23, 2017

Can you give examples of values for phone-type?
And you might run the method against all the user-agents of the unit-tests.
What about non-Android devices?

@serbanghita
Copy link
Collaborator

@ThorstenBux Mobile Detect library has the following KNOWN LIMITATIONS

The changes cannot be done to the script because of:

Mobile Detect script was designed to detect mobile devices. Implicitly other devices are considered to be desktop.

@ThorstenBux
Copy link
Author

@hgoebl for example on Android I'd expect to get the phone type: Pixel or Nexus 6 or Galaxy S6. These values are part of the user-agent on Android and on iOS if one uses a WebKit browser. So I think it should be possible to return them.

@serbanghita I don't quite understand your point. If it is a mobile phone it has a type i.e. Galaxy S6 and that type would still make it a mobile device and not a desktop device.

@serbanghita
Copy link
Collaborator

@ThorstenBux ok now I really understand the problem you are trying to solve.

We are going to have a solution on the next major version of Mobile Detect. Take a look at an example of regexes that are being checked in a certain context to determine the model or version.

I'm going to backup what @hgoebl said, this is a good start but it's a huge task that cannot be achieved without writing tests on each step of detection.

@hgoebl
Copy link
Owner

hgoebl commented Dec 27, 2017

I'm currently discussing with Google if they could provide us their device catalog including form-factor.
They have a device catalog including all Android devices. One of the properties of such a record is form-factor (phone, tablet, tv, ...). Would be quite easy to create a single regular expression each for phone and for tablet and nobody would have to maintain the regular expressions manually.
Currently, I don't know whether we get the list from Google.

@ThorstenBux for which case do you need the phoneType? Just for information or in the detection logic?

@hgoebl hgoebl reopened this Dec 27, 2017
@ThorstenBux
Copy link
Author

@hgoebl @serbanghita thanks for your positive response :). Unfortunately, regular expressions are one of my weak spots but if you could point me in the right direction I'm happy to support where I can. If it is only testing that would be fine as well.

I'd need the phoneType mainly for information. I'm involved in the artoolkitX (https://github.com/artoolkitx/artoolkit5) project and we maintain a server with camera calibrations for a lot of Android, iOS devices and desktop (WebCam) devices. So far we only dealt with native apps on Android and iOS which made it easy to look up the phoneType and uniquely identify a specific phone series.
Now we expand into the support of augmented reality (AR) inside the browser using jsARToolKit and we would like to integrate the camera calibration service into the jsARToolKit as well. For that, I'm looking for some possibility to get as much information about the device as possible from inside the browser. mobile-detect.js is a good start to get things moving but as said I'd need the phoneType to look-up a decent camera calibration for the specific phone. (What many don't know, because it is mostly taken care of in the background, without a decent calibration AR loses some of its magic ;-) .)

@serbanghita
Copy link
Collaborator

@ThorstenBux thank you for sharing your use-case! This actually motivates me to go forward with the deviceType detection. I cannot make any promises at the moment, I'm working towards this goal and currently I'm writing tests and researching.

@ThorstenBux
Copy link
Author

@serbanghita sounds good. I've done some research so far and it looks like there is nothing we can do if the client is a Firefox on mobile because the userAgent doesn't hold much information.
Here are the userAgents I collected so far

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36

Chrome on mobile:
Mozilla/5.0 (Linux; Android 7.0; HTC 10 Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.111 Mobile Safari/537.36

Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/M4B30Z) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.98 Mobile Safari/537.36

Firefox on mobile:
Mozilla/5.0 (Android 7.0; Mobile; rv:57.0) Gecko/57.0 Firefox/57.0

iPhone 6s Safari:
Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_2 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0 Mobile/15B202 Safari/604.1

From that it looks like we need to focus on WebKit browsers. Let me know if/how I can support you.

Cheers

@serbanghita
Copy link
Collaborator

@ThorstenBux btw, I looked over the projects on GitHub and the closest I found to what you need is https://github.com/piwik/device-detector - written in PHP.

@ThorstenBux
Copy link
Author

@hgoebl
Copy link
Owner

hgoebl commented Jan 9, 2018

Yes @ThorstenBux this is the list. But Google has much more columns and unfortunately only exposes those few fields. We need the form-factor (tablet, phone). With this additional column, we could generate regular expressions targeting all devices with Android. Imagine that!

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

Successfully merging this pull request may close these issues.

3 participants