This tutorial illustrates how to return a match for a Device Id. It shows how to first get the Device Id from a match, then get a match for that Device Id and return the value of the IsMobile property. This can be useful to look at devices that have already been matched at a previous date.
Code and Explanation
Match for device id example of using 51Degrees device detection. The example
shows how to:
Specify name of the data file and properties the dataset should be
Release the workset back into the pool of worksets to be reused in one
of the next matches.
Finally release the memory taken by the provider.
This example assumes you have compiled with 51Degrees.c and city.c.
This will happen automatically if you are compiling as part of the
Visual Studio solution. Additionally, when running the program, the
location of a 51Degrees data file must be passed as a command line
argument if you wish to use Premium or Enterprise data files.
The main focus of this example is on extracting the device ID and later
reusing it to obtain device information. Device ID is a more efficient
way of storing information about devices as the entire ID can be stored
as an array of bytes, where as when storing specific properties you would
be dealing with strings, integers and doubles for each property.
The 51Degrees device ID is composed of four numbers separated by hyphens.
Each number corresponds to the ID of the relevant profile. Each profile is
a collection of property - value pairs for one of the components.
A complete ID has one profile for each of the four components:
For more information on the Pattern data model and how various entities
are related please see:
For more information on how device detection works please see:
In this tutorial you have seen how to use the detector to retrieve the
property for a pre-defined Device ID 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
. For a full list of properties and the data files they exist in please see the