multi-device-switcher icon indicating copy to clipboard operation
multi-device-switcher copied to clipboard

Detect device by custom header.

Open kawaz opened this issue 10 years ago • 0 comments

For example, this is Amazon CloudFront. http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device

CloudFront don't send User-Agent to backend. But It can send the custom headers instead of User-Agent.

  • CloudFront-Is-Desktop-Viewer
  • CloudFront-Is-Mobile-Viewer
  • CloudFront-Is-SmartTV-Viewer
  • CloudFront-Is-Tablet-Viewer

Now, I add like this code.

if ( ! $this->device ) {
    if ($_SERVER['HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER') == "true" ) { /* do nothing */ }
    elseif ($_SERVER['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER') == "true" ) { $this->device = "smart"; }
    elseif ($_SERVER['HTTP_CLOUDFRONT_IS_TABLET_VIEWER') == "true" ) { $this->device = "tablet"; }
    elseif ($_SERVER['HTTP_CLOUDFRONT_IS_SMARTTV_VIEWER') == "true" ) { $this->device = "game"; /* ??? */ }
}

Really, I want to configure the list of set of header name and matching value on /wp-admin/, but it is very hard for me.

kawaz avatar Oct 27 '15 06:10 kawaz