How to determine whether user is on a mobile device from a plugin?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Is there a way to determine, from a plug-in, if a visitor/user is on a mobile device or not in NopCommerce (any version from 3.1 and up)?
6 years ago
To detect ..what app the client is using you can use simple codes on either client side or server side..

if you want to detect the browser with JavaScript  .. The following code should do ...also an working example


// keep adding all useragents for mobile browsers
var isChromium = window.chrome,
    winNav = window.navigator,
    vendorName = winNav.vendor,
    isOpera = winNav.userAgent.indexOf("OPR") > -1,
    isIEedge = winNav.userAgent.indexOf("Edge") > -1,
    isIOSChrome = winNav.userAgent.match("CriOS");

if(isIOSChrome){
   console.log('is Google Chrome on IOS');
   alert('is Google Chrome on IOS');
} else if(isChromium !== null && isChromium !== undefined && vendorName === "Google Inc." && isOpera == false && isIEedge == false) {
  console.log('is Google Chrome');
  alert('is Google Chrome');
} else {
   console.log('not Google Chrome');
   alert('not Google Chrome');
}



and in case you want to detect the browser from your plugin c#...

System.Web.HttpBrowserCapabilities browser = Request.Browser;
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.