Integration with Mobile Tools
twom - June 30, 2009 - 19:12
| Project: | Browscap |
| Version: | HEAD |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Hi,
I got a feature request for Mobile Tools to integrate with Browscap to detect if the visiting browser is a mobile device or not.
I created a quick fix for the browscap module to be able to work with Mobile Tools. This means that Mobile Tools will use the information from Browscap to do redirection, theme switching or give notifications.
/**
* Implementation of hook_is_mobile_device() provide by Mobile Tools module
*
*/
function browscap_is_mobile_device() {
$info = browscap_get_browser();
// detect device type
if ($info['ismobiledevice']) {
$type = 'mobile';
} else {
$type = 'desktop';
}
$groups = browscap_device_groups();
if (in_array($info['browser'], $groups)) {
$group = $info['browser'];
}
return array('type'=> $type, 'group' => $group);
}
/**
* Implementation of hook_device_groups() as provided by Mobile Tools module
*/
function browscap_device_groups() {
return array('iPhone', 'iPod', 'Android', 'Opera Mini', 'BlackBerry');
}I am thinking of making a contrib module for Mobile Tools to provide this functionality, unless the Browscap maintainers want to add this kind of code to their module?
Let me know

#1
Mobile Tools now has support to use Browscap to do device detectdion by using the 'ismobiledevice' property of the browser.
Something you can put in the Browscap documentation?
#2
I added a "related modules" part of the project page and put this in there.
Thanks for your work!
#3
Automatically closed -- issue fixed for 2 weeks with no activity.