Resources

Side-loaded Browser Handling

Resources

DeviceAtlas uses UserAgent strings to return information about devices. However there are a few exceptions to this rule. In some cases, additional browser-specific headers that need examined. Usually, the browser's UA string (HTTP_USER_AGENT) is enough for us to detect the device, due to the nature of some browsers, the other headers may need to be considered before passing the UA to DeviceAtlas.

Cloud APIs

DeviceAtlas Cloud APIs support both multiple headers and single UA string for the detection and is very easy to use. There is no need for any additional API call to handle the Side-loaded browsers when using the default mode.

Enterprise APIs 2.x

Starting with version 2.0, DeviceAtlas Enterprise APIs support both multiple headers and single UA string for the detection process. When using the multiple headers mode there is no need for any additional API call to handle the Side-loaded browsers.

Enterprise APIs 1.x

To correctly detect mobile devices with Side-loaded browsers, like Opera, an additional API call is needed. The following PHP code should help explain how this can be done.

<?php

// The user agent header
$ua = $_SERVER['HTTP_USER_AGENT'];

// Headers sent by some browsers
// If one of this headers exists then it holds the device hardware data
$specialCases = array(
    'HTTP_X_DEVICE_USER_AGENT',
    'HTTP_X_ORIGINAL_USER_AGENT',
    'HTTP_X_OPERAMINI_PHONE_UA',
    'HTTP_X_SKYFIRE_PHONE',
    'HTTP_X_BOLT_PHONE_UA',
    'HTTP_DEVICE_STOCK_UA',
    'HTTP_X_UCBROWSER_DEVICE_UA',
);

$uaSpecial = null;
foreach($specialCases AS $header) {
    if (array_key_exists($header, $_SERVER)) {
        $uaSpecial = $_SERVER[$header];
        break;
    }
}

// Get the device properties based on the user agent header
include '../Mobi/Mtld/DA/Api.php';
$tree = Mobi_Mtld_DA_Api::getTreeFromFile("json/sample.json");
$properties1 = Mobi_Mtld_DA_Api::getProperties($tree, $ua);

// If a special headers exists and you need to get information about
// device hardware then you must get properties based on the special header
if ($uaSpecial) {
    $properties2 = Mobi_Mtld_DA_Api::getProperties($tree, $uaSpecial);
} else {
    $properties2 = &$properties1;
}

// If no special header exists > get all the properties from $properties1
// If special header exists >
//      get browser properties from $properties1
//      get hardware properties from $properties2

echo '<pre>';
print_r($properties1);
echo '</pre>';

echo '<pre>';
print_r($properties2);
echo '</pre>';

 

 

Create amazing web presences on any screen
goMobi

Learn everything about mobile web technology
mobiForge

Evaluate your websites’ mobile readiness
mobiReady

© 2017 Afilias Technologies Ltd (dotMobi). All rights reserved.

This is a website of Afilias Technologies Ltd, a private company limited by shares, incorporated and registered in the Republic of Ireland with registered number 398040 and registered office at 6th Floor, 2 Grand Canal Square, Dublin 2, Ireland

IAB Certified Member