Instead of the hardcoding detection done in mobile_tools.module, is it possible to add support for the browsecap module?

It already detects a huge range of browsers.

Cheers,
Tim

Comments

twom’s picture

Hi,

A quick fix: if you add the following to the browscap module


/**
 *  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');
}

You will be able to use browscap as mobile device detection service. When going to the mobile tools settings page you will be able to select browscap as provider for the mobile device detection. Mobile Tools has the purpose of allowing different providers to give information about the device.

Let me know if this works for you!

Ps: the mobile-tools dev version fixes a little bug in the mobile tools themes setting page.

twom’s picture

Status: Active » Fixed
twom’s picture

I provided a small contrib module to support browscap. You can find it in the dev version.

tjharman’s picture

Hi Twom!

Thank you, I will check this out.

Kind Regards,

Tim

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.