|
| 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
-
config | An 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< 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...
|
|
The DeviceAtlas device detection API provides a way to detect devices based on the HTTP headers. Using the headers, the API returns device properties such as screen width, screen height, is mobile, vendor, model etc. If you want to use the DeviceAtlas API in a web application then it is strongly recommended to use DeviceApiWeb instead of this library.
The DeviceApiWeb is preferred when you want to get the properties from a real-time detection on user's device in a web application.
The DeviceApi is preferred when you want to get the properties outside a web application or from an off-line user-agent list or header set.
GetProperties(IDictionary<string, string> headers, string clientSide).
To get the most accurate results: 1- Pass the whole HTTP headers. 2- Use the DeviceAtlas client-side-component and pass the result.
When you have limited data you can also use this alternatives:
GetProperties(NameValueCollection headers).
GetProperties(IDictionary<string, string> headers).
GetProperties(string userAgent, string clientSide).
GetProperties(string userAgent).
Example usage:
IDictionary<string, string> headers = new Dictionary<string, string>() {
{"HEADER NAME", "HEADER VALUE"}
};
DeviceApi DeviceApi = new DeviceApi();
try
{
DeviceApi.LoadDataFromFile("/path/to/datafile.json");
Properties props = DeviceApi.GetProperties(headers);
// .... use the properties ....
if (props.Contains("isMobilePhone", true))
{
// it is a mobile phone
}
if (props.ContainsKey("model"))
{
string deviceModel = props["model"].AsString();
}
if (props.ContainsKey("yearReleased")) */
// {
/** int deviceModel = props["yearReleased"].AsInteger();
}
}
catch (...
- Author
- DeviceAtlas Limited
- Copyright
- Copyright (c) DeviceAtlas Limited 2022. All Rights Reserved. https://deviceatlas.com