Closed tanmayk closed 11 months ago
@tanmayk , for now I use the following way:
public function getBrowser()
{
// note: $this->mobileDetect below is \Detection\MobileDetect
$browsers = array_keys($this->mobileDetect->getBrowsers());
foreach ($browsers as $browser) {
if ($this->mobileDetect->is($browser)) {
return $browser;
}
}
// unknown browser
return self::UNKNOWN_BROWSER;
}
the only thing I noticed: the library detects mobile browsers, for desktop browser (at least for my UA "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36") the result for isChrome() = false. So, for browser name detection I have to use another library.
@tanmayk , same way call is() for values from $detect->getOperatingSystems() for get OS.
@tanmayk I realized that this can be confusing but the library was never intended to be a User-Agent detector but rather a detector for "mobile" and "tablet" devices. I tried to tackle this problem accurately a few years ago, but it was a cumbersome task.
How to directly get browser, it's version, mobile or tablet, it's OS & OS version. I know there are methods to like
isAndroid()
,isChrome()
etc, but we will need to check each & every method to find correct browser, os, right?.Is there something that will just return e.g. name of the browser. something like
$browser = $detect->getBrowser()
or$browser_version = $detect->getBrowserVersion();
?