|
| 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< 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...
|
|
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...
|
|
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 2023. All Rights Reserved.