The DeviceAtlas DeviceApi documentation
|
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.
| |||
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< PropertyName > | GetPropertyNames () | ||
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... | |
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.
<% 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 (... %>
|
inline |
Constructs a DeviceApiWeb instance with default configs.
|
inline |
Constructs a DeviceApiWeb instance with custom configs.
|
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.
<throws> ClientPropertiesException </throws>
|
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.
request | The request object to be used for detection. |
<throws> ClientPropertiesException </throws>