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

More...

Inheritance diagram for Com.DeviceAtlas.Device.DeviceApiWeb:
Com.DeviceAtlas.Device.DeviceApi Com.DeviceAtlas.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 (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...
 
 DeviceApiWeb ()
 Constructs a DeviceApiWebFrameWork instance with default configs. More...
 
 DeviceApiWeb (Config config)
 Constructs a DeviceApiWebFrameWork 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 Com.DeviceAtlas.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 Com.DeviceAtlas.Device.Config. Depending on the configs the properties may include user-agent dynamic properties and language/locale properties. More...
 
- Public Member Functions inherited from Com.DeviceAtlas.Device.DeviceApi
 DeviceApi ()
 Constructs a DeviceApi instance with default config. You can see the default configs in the class "Config". More...
 
 DeviceApi (Config config)
 Constructs a DeviceApi instance with custom config. 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 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 website. More...
 
virtual void LoadDataFromStream (Stream inputStream)
 Load the DeviceAtlas device detection data into the API from a 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...
 
string GetDataVersion ()
 The version of the data file. More...
 
virtual int GetDataCreationTimestamp ()
 Get the device data creation (JSON file) timestamp. More...
 
string GetDataCreationIso8601 ()
 The creation date/time of the loaded data file in ISO 8601 format. More...
 
virtual Properties GetProperties (string identifier)
 Get known properties for an identifier More...
 
Properties GetProperties (string identifier, string clientSideString)
 Get the properties of an identifier 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...
 
Properties GetProperties (NameValueCollection headers, string clientSideString)
 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...
 
Properties GetProperties (IDictionary< string, string > headers)
 
Properties GetProperties (IDictionary< string, string > headers, string clientSideString)
 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 Com.DeviceAtlas.Device.DeviceApi
static string GetApiVersion ()
 Get DeviceApi version. More...
 
- Public Attributes inherited from Com.DeviceAtlas.Device.DeviceApi
const string API_VERSION = "3.1.7"
 

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 DeviceApiWebCore library and GetProperties as shown bellow.

The GetProperties of DeviceApiWebCore, 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(HttpContext.Request) 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(HttpContext.Request);
    // .... use the properties ....
    if (properties.Contains("mobileDevice", true))
    {
        if (properties.ContainsKey("model"))
        {
            string deviceModel = properties["model"].AsString();
        }
    }
}
catch (...
%>
Author
DeviceAtlas Limited

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/4]

Com.DeviceAtlas.Device.DeviceApiWeb.DeviceApiWeb ( )
inline

Constructs a DeviceApiWeb instance with default configs.

◆ DeviceApiWeb() [2/4]

Com.DeviceAtlas.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.

◆ DeviceApiWeb() [3/4]

Com.DeviceAtlas.Device.DeviceApiWeb.DeviceApiWeb ( )
inline

Constructs a DeviceApiWebFrameWork instance with default configs.

◆ DeviceApiWeb() [4/4]

Com.DeviceAtlas.Device.DeviceApiWeb.DeviceApiWeb ( Config  config)
inline

Constructs a DeviceApiWebFrameWork 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/3]

Properties Com.DeviceAtlas.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>

◆ GetProperties() [2/3]

Properties Com.DeviceAtlas.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 Com.DeviceAtlas.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() [3/3]

Properties Com.DeviceAtlas.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 Com.DeviceAtlas.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: