What's Covered
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:
my $filename = "51Degrees-LiteV3.2.dat";
my $propertyList = "IsMobile"
my $cacheSize = 10000;
my $poolSize = 20;
my $provider = new FiftyOneDegrees::PatternV3::Provider( $dataFile, $properties, $cacheSize, $poolSize);
my $match = $provider->getMatchForDeviceId($userAgent)
$match->getValue('IsMobile')This example assumes you are running from the original subdirectory i.e. Device-Detection/perl/examples/ and the 51Degrees Perl module is installed.
Summary
In this tutorial you have seen how to use the detector to retrieve the IsMobile 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 IsCrawler , PriceBand , HardwareVendor and ScreenInchesWidth . For a full list of properties and the data files they exist in please see the Property Dictionary .