Copyright © 2014 by mTLD Top Level Domain Limited. All rights reserved.
Portions copyright © 2008 by Argo Interactive Limited.
Portions copyright © 2008 by Nokia Inc.
Portions copyright © 2008 by Telecom Italia Mobile S.p.A.
Portions copyright © 2008 by Volantis Systems Limited.
Portions copyright © 2002-2008 by Andreas Staeding.
Portions copyright © 2008 by Zandan.
dotMobi
The DeviceAtlas Device Detection API provides a way to detect devices based on the HTTP headers. Using the headers, the API returns device information such as screen width, screen height, is mobile, vendor, model etc.
DeviceApi.properties(user_agent_or_headers, client_side_properties)
To get the most accurate results: 1- Pass the whole HTTP headers. 2- Use the DeviceAtlas client-side-component and pass the result.
Example usage:
device_api = Mobi::Mtld::Da::Device::DeviceApi.new device_api.load_data_from_file "/path/to/datafile.json" # get all properties from the headers properties = device_api.properties headers # .... use the properties .... if properties.contains?("isMobilePhone", true) # it is a mobile phone end if properties.has_key?("model") device_model = properties.get("model").to_s end
Constructs a DeviceApi instance with default configs. You can see the default configs in the class “Config”.
config
Instance of Config. You can change the DeviceAtlas API
configs by creating an instance of Config and setting your custom config values then passing the instance to the DeviceApi constructor.
Get DeviceApi version.
Get the device data (JSON file) creation timestamp.
Get the device data (JSON file) revision.
Get the device data (JSON file) version.
Get known properties from a User-Agent or HTTP headers optionally merged with properties from the client side component. The client side component (JS) sets a cookie with collected properties. The client properties will over-ride any properties discovered from the main JSON data file.
user_agent_or_headers
User-Agent string or array of HTTP headers.
client_side_properties
String of client side properties with the format
the client side component provides.
return
Array of Property objects.
Get a set of available device property names. return
: Array of
PropertyName objects.
Load the DeviceAtlas device detection data into the API from a JSON file form the class path. The JSON data file is provided by the DeviceAtlas web-site.
json_data_file_path
Path to the JSON data file.
Load the DeviceAtlas device detection data into the API from a string.
json_data_string
JSON data string.