What's Covered
This tutorial illustrates the basic use of the 51Degrees API. It will show you how to create a provider, how to create a dataset and how to obtain a value for the IsMobile property.
Code and Explanation
Getting started example of using 51Degrees device detection.
The example shows how to:
string fileName = args[0];
DataSet dataSet = StreamFactory.Create(fileName, false);
Provider provider = new Provider(dataSet);
match = provider.Match(userAgent);
IsMobile = match["IsMobile"].ToString();This tutorial assumes you are building this from within the 51Degrees Visual Studio solution. Running the executable produced inside Visual Studio will ensure all the command line arguments are preset correctly. If you are running outside of Visual Studio, make sure to add the path to a 51Degrees data file as an argument.
Summary
In this tutorial you have seen how to use the detector to retrieve the IsMobile property for a pre-defined User-Agent string. The example can easily be modified to retrieve the value of any other property. Premium and Enterprise data files provide considerably more properties such as IsCrawler , PriceBand , HardwareVendor and ScreenInchesWidth . For a full list of properties and the data file versions they exist in please see the Property Dictionary .