Check out the latest documentation.

Client Side Overrides

 

Sometimes, the User-Agent alone does not contain enough information for certain properties. For example:

  • The User-Agent of an iPhone does not provide sufficient information to determine the particular iPhone model: this is a deliberate choice Apple have made. However, javascript running in an iPhone browser can be used to determine the screen size and therefore the numeric model version.
  • The device may be used in Landscape or Portrait orientation which is not a static feature of the device.

When used with the Enterprise version of the data set, the API can augment static data about devices with dynamic information determined by interrogating the device using javascript. .

Feature detection, when enabled, enhances properties in the 51Degrees dictionary to provider additional details. Once enabled, properties such as HardwareModel or Orientation will be populated or their values become more accurate.

Support for Client Side Overrides is API dependent. Future releases will include this functionality for unsupported APIs.

Using Client Side Overrides

Important : before invoking the FODPO() javascript object on the client side, a check must be carried out on the server for the presence of values in JavascriptHardwareProfile as shown in the snippet below:

										
										public
										
										
										class
										
										
										MyServlet
										
										
										extends
										
									 BaseServlet 
										
										{
										
										
										protected
										
										
										void
										
										
										processRequest
										
										
										(
										
									HttpServletRequest request
										
										,
										
									 
                                  HttpServletResponse response
										
										)
										
										
										throws
										
									 ServletException
										
										,
										
									 IOException 
										
										{
										
									
        response
										
										.
										
										
										setContentType
										
										
										(
										
										
										"text/html;charset=UTF-8"
										
										
										);
										
										
										try
										
										
										(
										
									PrintWriter out 
										
										=
										
									 response
										
										.
										
										
										getWriter
										
										
										())
										
										
										{
										
									

            out
										
										.
										
										
										println
										
										
										(
										
										
										"<!DOCTYPE html>"
										
										
										);
										
									
            out
										
										.
										
										
										println
										
										
										(
										
										
										"<html>"
										
										
										);
										
									
            out
										
										.
										
										
										println
										
										
										(
										
										
										"<head>"
										
										
										);
										
										
										if
										
										
										(
										
										
										super
										
										
										.
										
										
										getProvider
										
										
										(
										
									request
										
										).
										
										
										match
										
										
										(
										
									request
										
										)
										
										
										.
										
										
										getValues
										
										
										(
										
										
										"JavascriptHardwareProfile"
										
										
										)
										
										
										!=
										
										
										null
										
										
										)
										
										
										{
										
										
										//This is an iPhone so, deploy javasript for FODPO();
										
									
                out
										
										.
										
										
										println
										
										
										(
										
										
										"<script src=\"51D/core.js\" > </script>"
										
										
										);
										
									
                out
										
										.
										
										
										println
										
										
										(
										
										
										"<script>"
										
										
										+
										
										
										"new FODPO();"
										
										
										+
										
										
										"</script>"
										
										
										);
										
										
										}
										
										
										else
										
										
										{
										
										
										//Include alternative javascript if required.
										
										
										}
										
									
            out
										
										.
										
										
										println
										
										
										(
										
										
										"<title>Servlet MyServlet</title>"
										
										
										);
										
									            
            out
										
										.
										
										
										println
										
										
										(
										
										
										"</head>"
										
										
										);
										
									
            out
										
										.
										
										
										println
										
										
										(
										
										
										"<body>"
										
										
										);
										
									
            out
										
										.
										
										
										println
										
										
										(
										
										
										"<h1>Servlet MyServlet at "
										
										
										+
										
									 
                    request
										
										.
										
										
										getContextPath
										
										
										()
										
										
										+
										
										
										"</h1>"
										
										
										);
										
									
            out
										
										.
										
										
										println
										
										
										(
										
										
										"<HR>"
										
										
										);
										
									
            out
										
										.
										
										
										println
										
										
										(
										
										
										"<p> Data set name: "
										
										
										+
										
										
										super
										
										
										.
										
										
										getProvider
										
										
										(
										
									request
										
										).
										
										
										dataSet
										
										
										.
										
										
										getName
										
										
										()
										
										
										+
										
										
										"</p>"
										
										
										);
										
									
            out
										
										.
										
										
										println
										
										
										(
										
										
										"</body>"
										
										
										);
										
									
            out
										
										.
										
										
										println
										
										
										(
										
										
										"</html>"
										
										
										);
										
										
										}
										
										
										}
										
										
										}