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

detect the device type for other browsers (Huawei, Quark, MQQBrowser) #6878

Closed
sanchezzzhak opened this issue Oct 7, 2021 · 1 comment · Fixed by #6881
Closed

detect the device type for other browsers (Huawei, Quark, MQQBrowser) #6878

sanchezzzhak opened this issue Oct 7, 2021 · 1 comment · Fixed by #6881

Comments

@sanchezzzhak
Copy link
Collaborator

(CDY-TN90)

user_agent: Mozilla/5.0 (Linux; Android 10; HarmonyOS; TEST-XXXXX ; HMSCore 6.1.0.314) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.93 HuaweiBrowser/11.1.5.310 Mobile Safari/537.36
device:
  type: tablet
  brand: ""
  model: ""

(vivo Y51A)

user_agent: Mozilla/5.0 (Linux; U; Android 5.1.1; zh-CN; TEST-XXXXX Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 Quark/5.3.3.191 Mobile Safari/537.36
device:
  type: tablet
  brand: ""
  model: ""

(vivo X7Plus)

Mozilla/5.0 (Linux; U; Android 7.1.1; zh-cn;  TEST-XXXXX Build/NMF26F) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/11.2 Mobile Safari/537.36
device:
  type: tablet
  brand: ""
  model: ""

I think that it needs to be corrected somewhere here

if (null === $this->device && 'Android' === $osFamily
&& $this->matchUserAgent('Chrome/[\.0-9]*')
) {
if ($this->matchUserAgent('Chrome/[\.0-9]* (?:Mobile|eliboM)')) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_SMARTPHONE;
} elseif ($this->matchUserAgent('Chrome/[\.0-9]* (?!Mobile)')) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_TABLET;
}
}

@sanchezzzhak
Copy link
Collaborator Author

sanchezzzhak commented Oct 7, 2021

approximate solution fix:

if (null === $this->device && 'Android' === $osFamily
            && $this->matchUserAgent('Chrome/[\.0-9]*')
        ) {
            if ($this->matchUserAgent('(?:Mobile|eliboM) Safari/')) {
                $this->device = AbstractDeviceParser::DEVICE_TYPE_SMARTPHONE;
            } elseif ($this->matchUserAgent('(?!Mobile )Safari/')) {
                $this->device = AbstractDeviceParser::DEVICE_TYPE_TABLET;
            }
        }

do us need such fix?

sanchezzzhak added a commit to sanchezzzhak/device-detector that referenced this issue Oct 16, 2021
@sanchezzzhak sanchezzzhak linked a pull request Oct 16, 2021 that will close this issue
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 a pull request may close this issue.

1 participant