The DeviceAtlas DeviceApi documentation
Public Member Functions | List of all members
Mobi.Mtld.DA.Device.DeviceApiWeb Class Reference

More...

Inheritance diagram for Mobi.Mtld.DA.Device.DeviceApiWeb:
Mobi.Mtld.DA.Device.DeviceApi

Public Member Functions

 DeviceApiWeb ()
 Constructs a DeviceApiWeb instance with default configs. More...
 
 DeviceApiWeb (Config config)
 Constructs a DeviceApiWeb instance with custom configs. More...
 
Properties GetProperties ()
 Get the Device properties for the current request. The most suitable headers are extracted and used for detection and property lookup.
If the client-side-component has been used and the client-side properties exists in the client-side cookie, then the client-side properties will be included in the result and the device detection for certain devices such as iPhone models will be done more accurately.
You can change the API's configs using Mobi.Mtld.DA.Device.Config. Depending on the configs the properties may include user-agent dynamic properties and language/locale properties. More...
 
Properties GetProperties (HttpRequest request)
 Get the Device properties for the given HttpRequest object. The most suitable headers are extracted and used for detection and property lookup.
If the client-side-component has been used and the client-side properties exists in the client-side cookie, then the client-side properties will be included in the result and the device detection for certain devices such as iPhone models will be done more accurately.
You can change the API's configs using Mobi.Mtld.DA.Device.Config. Depending on the configs the properties may include user-agent dynamic properties and language/locale properties. More...
 
- Public Member Functions inherited from Mobi.Mtld.DA.Device.DeviceApi
 DeviceApi ()
 Constructs a DeviceApi instance with default configs. You can see the default configs in the class "Config". More...
 
 DeviceApi (Config config)
 Constructs a DeviceApi instance with custom configs. More...
 
void SetConfig (Config config)
 Updates DeviceApi instance with new configs.

See also
Config
Parameters
configAn instance of Config, you can change the DeviceAtlas API configs by creating an instance or Config and setting your preferences config values then passing the instance to the DeviceApi constructor.

 
virtual void LoadDataFromFile (string jsonDataFilePath)
 Load the DeviceAtlas device detection data into the API from a JSON file. The JSON data file is provided by the DeviceAtlas web-site. More...
 
virtual void DownloadAndLoadDataFile (DataFileConfig dataFileConfig)
 Downloads and loads the DeviceAtlas device detection data into the API. The data file is downloaded from the DeviceAtlas web-site. More...
 
virtual void DownloadAndLoadDataFile (string dataFileDownloadUrl)
 Downloads and loads the DeviceAtlas device detection data into the API from a JSON file. The JSON data file is downloaded from the DeviceAtlas web-site. More...
 
virtual void LoadDataFromStream (Stream inputStream)
 Load the DeviceAtlas device detection data into the API from an input stream. More...
 
ReadOnlyCollection< PropertyNameGetPropertyNames ()
 Get a set of all possible property names. Note that the client-side properties are not included in this set More...
 
string GetDeviceAtlasApiVersion ()
 Get DeviceApi version. More...
 
virtual string GetDataVersion ()
 Get the device data (JSON file) version. More...
 
virtual int GetDataCreationTimestamp ()
 Get the device data creation (JSON file) timestamp. More...
 
int GetDataRevision ()
 Get the device data generation revision. Deprecated use GetDataCreationTimestamp() for comparing data generation. More...
 
virtual Properties GetProperties (string userAgent)
 Get known properties for a User-Agent. More...
 
virtual Properties GetProperties (string userAgent, string clientSideProperties)
 Get known properties merged with properties from the client side component. The client side component (JS) sets a cookie with collected properties. The contents of this cookie must be passed to this method. The client properties will over-ride any properties discovered from the main JSON data file. More...
 
virtual Properties GetProperties (NameValueCollection headers)
 Get known properties for a set of HTTP headers. The DeviceApi gets all the request HTTP headers and will precisely detect the device and find property values by all usable headers. More...
 
virtual Properties GetProperties (NameValueCollection headers, string clientSideProperties)
 Get known properties for a set of HTTP headers merged with properties from the client side component. The DeviceApi gets all the request HTTP headers and will precisely detect the device and find property values by all usable headers. The client side component (JS) sets a cookie with collected properties. The contents of this cookie must be passed to this method. The client properties will over-ride any properties discovered from the main JSON data file. More...
 
virtual Properties GetProperties (IDictionary< string, string > headers)
 Get known properties for a set of HTTP headers. The DeviceApi gets all the request HTTP headers and will precisely detect the device and find property values by all usable headers. More...
 
virtual Properties GetProperties (IDictionary< string, string > headers, string clientSideProperties)
 Get known properties for a set of HTTP headers merged with properties from the client side component. The DeviceApi gets all the request HTTP headers and will precisely detect the device and find property values by all usable headers. The client side component (JS) sets a cookie with collected properties. The contents of this cookie must be passed to this method. The client properties will over-ride any properties discovered from the main JSON data file. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Mobi.Mtld.DA.Device.DeviceApi
static string GetApiVersion ()
 Get DeviceApi version. More...
 
- Public Attributes inherited from Mobi.Mtld.DA.Device.DeviceApi
const string API_VERSION = "DEVICE_API_VERSION"
 Api version More...
 

Detailed Description

A small extension to the core DeviceApi for current client or to permit passing of an HttpRequest object.

When detecting user's device as real-time on a website it is strongly recommend to use the DeviceApiWeb library and GetProperties as shown bellow.

The GetProperties of DeviceApiWeb, automatically detects the availability of the client-side properties and will use them for detection. If you want to have a more accurate detection (specially for apple devices) or have the client side properties included in the property sets, simply include the DeviceAtlas client-side component JavaScript library in the pages.

The GetProperties() method in this class extracts the most suitable request headers.

Example usage:

<%
DeviceApiWeb deviceApi = new DeviceApiWeb();
// loading data can be slow - it is recommended to store loaded API in the
// WebContext or wrap in a Singleton.
try
{
    deviceApi.LoadDataFromFile("/path/to/datafile.json");
    // get all properties from the current request
    Properties properties = deviceApi.GetProperties();
    // .... use the properties ....
    if (properties.Contains("mobileDevice", true))
    {
        if (properties.ContainsKey("model"))
        {
            string deviceModel = properties["model"].AsString();
        }
    }
}
catch (...
%>
Author
DeviceAtlas Limited

Constructor & Destructor Documentation

◆ DeviceApiWeb() [1/2]

Mobi.Mtld.DA.Device.DeviceApiWeb.DeviceApiWeb ( )
inline

Constructs a DeviceApiWeb instance with default configs.

◆ DeviceApiWeb() [2/2]

Mobi.Mtld.DA.Device.DeviceApiWeb.DeviceApiWeb ( Config  config)
inline

Constructs a DeviceApiWeb instance with custom configs.

Parameters
configAn instance of Config, you can change the DeviceAtlas API configs by creating an instance or Config and setting your custom config values then passing the instance to the DeviceApi constructor.

Member Function Documentation

◆ GetProperties() [1/2]

Properties Mobi.Mtld.DA.Device.DeviceApiWeb.GetProperties ( )
inline

Get the Device properties for the current request. The most suitable headers are extracted and used for detection and property lookup.
If the client-side-component has been used and the client-side properties exists in the client-side cookie, then the client-side properties will be included in the result and the device detection for certain devices such as iPhone models will be done more accurately.
You can change the API's configs using Mobi.Mtld.DA.Device.Config. Depending on the configs the properties may include user-agent dynamic properties and language/locale properties.

Returns
The found properties

<throws> ClientPropertiesException </throws>

◆ GetProperties() [2/2]

Properties Mobi.Mtld.DA.Device.DeviceApiWeb.GetProperties ( HttpRequest  request)
inline

Get the Device properties for the given HttpRequest object. The most suitable headers are extracted and used for detection and property lookup.
If the client-side-component has been used and the client-side properties exists in the client-side cookie, then the client-side properties will be included in the result and the device detection for certain devices such as iPhone models will be done more accurately.
You can change the API's configs using Mobi.Mtld.DA.Device.Config. Depending on the configs the properties may include user-agent dynamic properties and language/locale properties.

Parameters
requestThe request object to be used for detection.
Returns
The found properties

<throws> ClientPropertiesException </throws>


The documentation for this class was generated from the following file: