# DeviceAtlas Device Detection for Apps # The DeviceAtlas Device Detection API for Apps provides a way to detect devices based on the make/model strings. Using the make and model information, the API returns device information such as screen width, screen height, is mobile, vendor, model etc. To see a full list of properties in DeviceAtlas please visit: https://deviceatlas.com/resources/available-properties . ### Make-Model String Format ### DeviceAtlas expects the make/model string in a specific format. This format consists of values separated by a space character, where the mandatory values are manufacturer and model. The string is the same for all platforms: ``` "Make Model" ``` The term "Make" stands for manufacturer and the term "Model" stands for a model number. It is important to pass the string to the DeviceAtlas API in the lowercase form when using lowercased data file. Other modifications to the make or model strings obtained from the device may result in non-identification or mis-identification. For more information please visit: https://deviceatlas.com/resources/getting-started-enterprise-for-apps ### Data File ### The DeviceAtlas API relies on a device data file to function. DeviceAtlas provides daily data file updates so it is recommended to download the data file on a regular basis. This can be done manually from your account page or automated via the https://deviceatlas.com/getJSON page. For more information please see: https://deviceatlas.com/resources/getting-the-data ### Dependencies ### This library does not depend on any third party libraries. ### Library ### The DeviceAtlas Device Detection API consists of three libraries and each library has a separate DLL file. #### DeviceAtlas Common (deviceatlas-common-x.x.dll) #### Contains the shared libraries which are common between the DeviceAtlas APIs. When using the DeviceApi and DeviceApiWeb, the DLL file must be included to the project. #### DeviceApi (deviceatlas-deviceapi-x.x.dll) #### The main DeviceApi that loads the Device data and detects and returns the properties for a set of request headers or the user-agent. Client-side properties can be optionally passed to this library to get more accurate results. #### DeviceApiWeb #### A small extension to the main API that allows automatic extraction of the request headers and client-side properties from the. It is preferred to use this library for real-time device detections in web applications. ##### .NET Framework (deviceatlas-deviceapiweb-x.x.dll) ##### .NET Framework 2.0 is the minimum supported version. The deviceatlas-deviceapi-x.x.dll and deviceatlas-common-x.x.dll libraries are also required. ##### .NET Core (deviceatlas-deviceapiwebcore-x.x.dll) ##### .NET Core 2.1 is the minimum supported version. The deviceatlas-deviceapi-x.x.dll and deviceatlas-common-x.x.dll libraries are also required. #### Basic Usage #### The API can be used as follows: To lookup the properties by passing the make/model string to the API: ```csharp // (1) Create an instance with default API settings. DeviceApiWeb deviceApi = new DeviceApiWeb(); // (2) Load the data file in a try/catch block as several exceptions may be thrown. try { deviceApi.LoadDataFromFile("/path/to/datafile_lowercased.json"); } catch (Exception e) { // handle the exceptions related to loading the data file } # (3) Look up device properties based on a particular make/model string string makeModel = "samsung SM-N9005".ToLower(); Properties properties = deviceApi.GetProperties(makeModel); # (4) Use the properties - e.g. detect mobile device. // if there is a property named "mobileDevice" and the value is true if (properties.Contains("mobileDevice", true)) { // example 1: Get the screen width for image optimization int displayWidth = properties.ContainsKey("displayWidth")? properties["displayWidth"].AsInteger(): 100; // example 2: Get the device vendor name string vendor = properties.ContainsKey("vendor")? properties["vendor"].AsString(): ""; // example 3: Touch screen optimization bool useBiggerIcons = properties.Contains("touchScreen", true); // example 4: Send Geo Location JS to client? bool supportsGeoLocation = properties.Contains("js.geoLocation", true); } ``` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _ Copyright (c) DeviceAtlas Limited 2021. All Rights Reserved. https://deviceatlas.com _ <!-- HTML+JS for document formatting when opened in browser --> <div class="btn-group" id="main-menu" style="float:right"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Menu<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="README.html">Main</a></li><li><a href="README.DeviceApi-Web.html">Device Detection for Web</a></li><li class="disabled"><a href="README.DeviceApi-Apps.html">Device Detection for Apps</a></li><li><a href="README.DeviceApi-Config.html">Device Detection API Config</a></li><li><a href="./DeviceApiDocs/classes.html">Device API Docs</a></li><li class="divider"></li><li><a href="README.CarrierApi.html">Carrier Identification API</a></li><li><a href="./CarrierApiDocs/classes.html">Carrier API Docs</a></li><li class="divider"></li><li><a href="README.ClientSide.html">Client-side Component</a></li><li><a href="README.ConnectivityAnalyser.html">Connectivity Analyser</a></li></ul></div>