Mobile Device Type Detection in Sitefinity
To make my responsive sites offer a better experience, I want to be able to detect the type of mobile device and make decisions. e.g. A tablet might be able to display something that a phone can't.
Obviously, browser agent sniffing is a nasty no-go, but the standard ASP.NET Request.Browser.IsMobileDevice property makes no distinction for the device type other than it's "mobile".
I'm interested in what others do, and whether anyone has experience with using 3rd party solutions with Sitefinity, such as 51Degrees - which is slick but involves extra $$.
Hi Mike,
You can try the approach discussed in that forum:
http://stackoverflow.com/questions/14851649/how-to-detect-tabletany-requests
Regards,
Svetoslav Manchev
Telerik
Hi,
Funny you should say that, as I'm currently testing a piece of code I wrote, which is a slight modification to code I "borrowed" from the bottom of that forum thread
private
static
bool
IsTablet(
string
userAgent,
bool
isMobile)
var r =
new
Regex(
"Tablet|iPad|PlayBook|BB10|Z30|Nexus 10|Nexus 7|GT-P|SCH-I800|Xoom|Kindle|Silk|KFAPWI"
, RegexOptions.IgnoreCase);
var isTablet = r.IsMatch(userAgent) && isMobile;
return
isTablet;
Called as:
IsTablet(Request.UserAgent, Request.Browser.IsMobileDevice);
This seems to work for common tablets, but I'm not so sure of the various convertables, and is obviously prone to being broken by the Mobile/Tablet market - where new devices appear at an alarming rate.
The 51Deg solution has some attractions in that is regularly updated (weekly) and more advanced in its agent-string analysis, but the downside is obviously the extra $$ (although not so bad if running multiple websites on the one host - sounds like I'm talking myself into it - LOL) and I am unsure if the httpHandler (which basically intercepts all requests) will interfere with Sitefinity.