Comments (10)
@StevenMapes thank you for this valuable contribution!
For starters I will add the getUserAgent()
method right away and will be available in 2.5 version.
I am preparing a similar implementation to getDetails()
, check it here https://github.com/serbanghita/Mobile-Detect/wiki/Roadmap under 'What we need'. I will add some of you ideas there. I will commit it to a branch called '3.0' in the next days/weeks.
Are you interested in reviewing it together?
from mobile-detect.
Certainly, I saw what you were doing and it's certainly something that I'd like to help out with as I know I'll make use of it ;)
I made some further changes to my fork to help return the device names a little easier/
I added the following array keys into the phoneDevices array (really these should be somewhere else but I'll see what you do with brand 3.0). These are so I can break out Windows Phone and Android devices closer to their device names.
// Android
'AndroidManuf' => 'Android .*?; [a-z]{2}-[a-z]{2}; (?P<name>.+?) Build',
'WindowsManuf' => 'Windows Phone OS .*?; .*?; .*?; (?P<name>.+?)\)',
Next I modified my getPropertyDetail method to become this
public function getPropetyDetail($method) {
if (!method_exists($this, $method)) {
throw new UnexpectedValueException('Method name ' . $method . ' was not expected');
}
foreach ($this->$method() as $name => $regex) {
$check = $this->{'is' . $name}();
if ($check) {
// Match found! Check to see if the RegEx will tell us the device name
if (! stristr($regex, '(?P<name>')) {
return $name;
}
$regex = str_replace('/', '\/', $regex);
$res = preg_match('/' . $regex . '/is', $this->userAgent, $matches);
if ($res) {
if (substr_count($matches['name'], ';') > 0) {
// The match found at least one semi colon, take the 2nd portion regardless of how many there are
$parts = explode(";", $matches['name']);
return trim($parts[1]);
}
return $matches['name'];
}
// Failover
return $name;
}
}
return '';
}
I then ran a test over around 300 Useragents from the tests/* files.
Previously it returned these unique devices
[device] => Array
(
[0] => AsusTablet
[1] => AcerTablet
[2] => Kindle
[3] => iPhone
[4] => iPad
[5] => BlackBerry
[6] => CobyTablet
[7] => CubeTablet
[8] => Dell
[9] => NexusTablet
[10] => GenericTablet
[11] => HTC
[12] => Motorola
[13] => MotorolaTablet
[14] => GenericPhone
[15] => Samsung
[16] => Pantech
[17] => SamsungTablet
[18] => Nexus
[19] => Sony
[20] => Palm
Now the "device" list return
[device] => Array
(
[0] => AsusTablet
[1] => AcerTablet
[2] => Allegro
[3] => ALCATEL ONE TOUCH 918D
[4] => Kindle
[5] => iPhone
[6] => iPad
[7] => asus_laptop
[8] => BlackBerry
[9] => C771
[10] => CobyTablet
[11] => CubeTablet
[12] => Dell
[13] => NexusTablet
[14] => GenericTablet
[15] => HTC
[16] => IncredibleS_S710e
[17] => U8660
[18] => HUAWEI-U8850
[19] => VS910 4G
[20] => LS670
[21] => LG-P700
[22] => LG-L160L
[23] => LG-F160S
[24] => LG E-900
[25] => LG-C900
[26] => LG-C900k
[27] => LG-E900
[28] => LG-E900h
[29] => LG-Optimus 7
[30] => Motorola
[31] => MotorolaTablet
[32] => GenericPhone
[33] => Samsung
[34] => Pantech
[35] => A2
[36] => SamsungTablet
[37] => Nexus
[38] => OMNIA 7
[39] => Sony
[40] => TSUNAGI
[41] => Blade
[42] => N880e_Dawoer_Fulllock
[43] => V965W
[44] => Windows Phone - Internet 7
[45] => Palm
[46] => XDeviceEmulator
[47] => N880E
[48] => sdk
)
from mobile-detect.
Hi,
Is there chance to return phone/tablet model?
'isBrand' => 'Samsung',
'isModel' => 'SGH-i677',
from mobile-detect.
@Lechus yes, this is exactly what I'm working on for v.3.0
from mobile-detect.
Any update on this? Is it possible to get a preview of MobileDetect with these methods? thanks
from mobile-detect.
@maxxer We are presently discussing the API for this very feature. I expect to start working on it over the next 2 weeks or so.
from mobile-detect.
awesome!
what about the devel_3.x branch? is that usable? thanks
from mobile-detect.
No I wouldn't use devel_3.x or any other 3.x branch since there is a significant API undertaking and most things are broken at this point. Once we get to a stable point in dev with the API we'll make a post about it.
from mobile-detect.
How far are we with getDetails()
from mobile-detect.
I experimented with this, see https://github.com/serbanghita/Mobile-Detect/tree/devel-3-workinprogress/lib, and it's very hard to maintain. I'll keep the a tight focus to Mobile Detect, and that is to detect the mobile environment and focus on the separation of mobiles vs tablets.
from mobile-detect.
Related Issues (20)
- Safari on iPad: completely incorrect reports HOT 1
- Trying to get in touch regarding a security issue HOT 2
- MD v 3.74 - PHP Parse error: syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST) in Mobile_Detect.php on line 245 HOT 1
- How to check Desktop site setting On OR Off in mobile browser
- isMobile doesn't cache matches HOT 2
- isEdge() return false on Edge Browser
- 4.8.x HOT 4
- isMobile and IsTablet failing on ios devices - using safari HOT 1
- Port functionality from `jenssegers/agent` HOT 11
- Restore implicit use of `HTTP_USER_AGENT` in 4.8.x branch HOT 3
- Chrome's user agent reduction results in no longer detecting Android tablets as a tablet device HOT 1
- Getting a Parse error on the latest version (4.8.03) on PHP 7.1.33 HOT 4
- Google SERP links open as the mobile version HOT 5
- [bug] No user-agent has been set HOT 18
- [bug] breaking change pushed as patch HOT 3
- Need advice on `No valid user-agent has been set` PHP Fatal error HOT 4
- Tablet IOS detection HOT 1
- I dont understand HOT 8
- php 8.4 - implicit nulls are deprecated HOT 1
- Windows Wechat
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mobile-detect.